Given an integer n, which represents the number of arrays, read sequentially and perform operations.
(The array is read from 0)
#include <iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int a[10];
int n;
cin>>n;
int maxx=0;
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(int i=0; i<n; i++)
{
if(a[i]>a[maxx])
{
maxx=i;
}
}
printf("最大下标:%d\n最大值%d\n",maxx,a[maxx]);
return 0;
}
Sample output: