实验六 数组

输入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;
}
原文地址:https://www.cnblogs.com/reaper/p/3391738.html