你这个肯定错啊,如果第一个不是你输入的数字,马上执行else就跳出循环了,后面的就不会判断了
int flag=0;
Scanner xuruiqi = new Scanner(System.in);
System.out.println("请输入数字");
int number = xuruiqi.nextInt();
for (int i = 0; i < score.length; i++) {
if (number == score[i]) {
System.out.println("该数字存在");
flag = 1;
break;
}
}
if (flag ==0) {
System.out.println("该数字不存在");
}
import java.util.*;
public class shuzhu {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] arr = {15,12,33,66};
System.out.println("输入数字:");
int num = input.nextInt();
boolean isin = false;
for(int i=0; i
isin = true;break;
}
}
if(isin)
System.out.println("在数组里");
else
System.out.println("不在数组里");
}
}
int i, flag = 0;
for ( i = 0; i < a.length; i++ )
{
if ( myarray[i] == 'a' )
{
flag = 1;
break;
}
}
if (flag == 0){
System.out.println("不在");
}
esle{
System.out.println("在")
}
还需要吗?