当前位置:学者斋 >

计算机 >C语言 >

C语言程序改错习题

C语言程序改错习题

行动是通向成功的唯一途径。以下是小编为大家搜索整理的C语言程序改错习题,希望能给大家带来帮助!更多精彩内容请及时关注我们应届毕业生考试网!

C语言程序改错习题

在考生文件夹下,给定程序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************/

if(max

if (max > a[i])

{

max = a[i];

/************found************/

pos=i;

i = pos;

}

printf("The max is: %d ,pos is: %dn", max , pos);

}

标签: 习题 改错 语言
  • 文章版权属于文章作者所有,转载请注明 https://xuezhezhai.com/jsj/cyuyan/zxl36.html