全国计算机等级考试C语言考试程序改错题(11)
在考生文件夹下,给定程序MODI.C的功能是: 求一维数组a中的最大元素及其下标。 例如,当一维数组a中的元素为:1,4,2,7,3,12,5,34,5,9, 程序的输出应为:The max is: 34,pos is: 7 。
#include #include void main() { int a[10]={1,4,2,7,3,12,5,34,5,9},i,max,pos; max = a[0]; pos = 0; for ( i=1; i<10; i++) /************found************/
{ /************found************/
pos =i; } printf("The max is: %d ,pos is: %d ", max , pos); } 相关资料 |