k = (char *)malloc(10 * sizeof(char))
j = (char *)malloc(10 * sizeof(char))
第一种方法数组内容自定义 #include <stdio.h> main() { int a[10],n,i scanf("%d",&n) for(i=0i<10i++)scanf("%d",&a[i]) for(i=0i<10i++)if(n==a[i])break if(i==10)printf("no found")else printf("%d",i) system("PAUSE") } 第二种方法数组内容已定义 #include <stdio.h> main() { int a[10]={0,1,2,3,4,5,6,7,8,9},n,i scanf("%d",&n) for(i=0i<10i++)if(n==a[i])break if(i==10)printf("no found")else printf("%d",i) system("PAUSE") }欢迎分享,转载请注明来源:内存溢出
评论列表(0条)