您的位置:首页 > 其它

实验六 数组

2013-10-28 09:17 134 查看
输入n个整数,将它们存入数组a中。输出最大值和它所对应的下标。

#include<stdio.h>
int main()
{
int i,n,m,max;
int count[9];

n=10;
for(i=0;i<n;i++){ //使用for循环输入5个数
printf("enter a num:");
scanf("%d",&m);//赋值到m

count[i]=m;//存入数组
}
max=0;
for(i=0;i<n;i++){//算出最大值及下标
if(count[i]>max)
max=count[i];
}
printf("the max number=%d and index=%d",max,i-1);//输出

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: