本文共 434 字,大约阅读时间需要 1 分钟。
#include<stdio.h> #define N 10 void main() { int a[N]; int num,i; char ch='n'; printf("Input an array:\n"); for(i=0;i<N;i++) scanf("%d",&a[i]); printf("Output the array:\n"); for(i=0;i<N;i++) printf("%d ",a[i]); printf("\n"); printf("Input a number:\n"); scanf("%d",&num); printf("start finding\n"); for(i=0;i<N;i++) if(num==a[i]) { ch='Y'; printf("%d is the %dth number in the array\n",num,i+1); } if(ch=='n') printf("no found\n"); }转载地址:http://frnvi.baihongyu.com/