数组搜索问题 [英] Array Search Problem

查看:56
本文介绍了数组搜索问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在数组中搜索字符串,如果字符串存在于数组中,它将不会进入if语句,我正在使用下面的代码,它只是不适合我,任何想法?

展开 | 选择 | Wrap | 行号

解决方案

这就是我的工作,那是否实用?

展开 | 选择 | 换行 | 行号


< blockquote> @ziycon


翻译成单词:

如果字符串不在数组中且字符串不为空则则打印字符串。


......到底发生了什么。


虽然我先测试字符串(第二个表达式如果没有执行,如果第一个表达式求值为 FALSE

展开 | 选择 | Wrap | 行号


基本上如果字符串不存在在数组中,字符串不是空的然后它会打印出来但是发生了什么,即使字符串在数组中它仍然打印出字符串,它不应该做!


I''m trying to search an array for a string and if the string exists in the array it wont go into the if statement, I''m using the below code, It just wont work for me, any ideas?

Expand|Select|Wrap|Line Numbers

解决方案

This is what I do, would that be practical?

Expand|Select|Wrap|Line Numbers


@ziycon
translated into words:
if string is not in array and string is not empty then print string.

...exactly what has happened.

although I''d test for the string first (the second expression is not executed if the first expression evaluates to FALSE)

Expand|Select|Wrap|Line Numbers


Basicly if the string doesn''t exist in the array and the string isn''t empty then it will print out but whats happening is even if the string is in the array it still prints out the string, which it shouldn''t do!


这篇关于数组搜索问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆