KilluaZoldyck 2020-01-02
#include<stdio.h> int main() { int x, i, a[10] = { 11,5,78,22,53,66,34,89,45 };//数组初始化 printf("请输入要查找的数据:\n"); scanf_s("%d", &x); for (i = 0; i < 10; i++)//循环查找,存在相等元素提前结束循环,否则i++继续比较 if (a[i] == x) break; if (i < 10) printf("%d在数组的第%d个单元\n", x, i); printf("Not Found!\n"); return 0; }