在一个无序数组中查找具体的某个数字n。
#include <stdio.h>
#include <stdlib.h>
int main(){
int arr[4] = { 9, 5, 2, 7 };
int to_find = 2;
int i = 0;
for (i = 0; i < 4; ++i){
if (arr[i] == to_find){
printf("找到了 !\n");
break;
}
}
if (i == 4){ //当 i 为 4 是,说明数组找完了但没找到指定数字
printf("没找到 !\n");
}
system("pause");
return 0;
}