Tuesday, 23 September 2014

Lab 3 cont

int K[] = { 4, 8, 5};
void setup(){
 check(5);
 check(4);
 check(9);
}
 void check(int j){
 int c = 0;
 for(int i = 0; i < K.length; i++){
 if( j == K[i]){println(j+" has index = "+i+" in K"); c++;} }
 for(int i = 0; i < K.length; i++){
 if( j != K[i] && c == 0){println(j+" is not in K"); c++;} }
}

No comments:

Post a Comment