Problem description
For a given array of integers a[], look for the maximum value and return the subscript. Input format integer array a[], the number of array elements is less than 1 equals 100. The input data is divided into two lines: the first line has only one number, which indicates the number of array elements, and the elements of the second behavior array. Output format output maximum value, and its subscript sample input 33 2 1 sample Output 3 0 Answer:
#include <stdio.h>
#include <string.h>
int main (int argc, const char * argv[]) {
int n;
scanf ("%d", &n);
Input data
int a[n];
int i;
for (i = 0;i < N;++i) {
scanf ("%d", &a[i]);
}
Determining the maximum Value
int max = a[0];
for (i = 1; I <n;i + +) {
if (max <a[i]) {
max = A[i];
}
}
The maximum value in the input array and the corresponding index
printf ("%d", max);
for (i = 0; i < n; i + +) {
if (max = = A[i]) {
printf ("%d", I);
}
}
return 0;
}
Blue Bridge Cup--look for the maximum value in the array