如果数组中存在1,2,3元素,请使用该数组打印true。它们不必在数组中连续。否则打印为false ...
答案 0 :(得分:0)
public class SequenceCheck{
static void sequenceCheck(int arr[]){
int c= 0;
for( int i =0;i<arr.length;i++){
if (arr[i]==1)
c++;
if (arr[i]==2)
c++;
if (arr[i]==3)
c++;
}
if (c==3)
System.out.println("true");
else
System.out.println("false");
}
public static void main(String args[]){
int array[]={1,2,3,4,5,6,7,8,9,0};
sequenceCheck(array);
}
}