在这里插入代码片#include<stdio.h>
#include<Windows.h>
#pragma warning(disable:4996)
int max;
int fun(int a[], int n){
int i = 0;
int pos = 0;
max = a[0];
for (; i < n; i++){
if (max < a[i]){
max = a[i];
pos = i;
}
}
return pos;
}
int main()
{
int a[10] = { 1, 4, 2, 7, 3, 12, 5, 34, 5, 9 };
int n = sizeof(a) / sizeof(a[0]);
int ret = fun(a, n);
printf("最大数下标是:%d 最大数为:%d", ret,a[ret]);
system("pause");
}