Home > Back-end >  R7-7 to find the maximum number of the elements in an array, and points out its location (10 points)
R7-7 to find the maximum number of the elements in an array, and points out its location (10 points)

Time:05-20

Find out the value of one of the biggest element in an array, and points out that it is which one element,

Input format:
From the keyboard to 10 integer array element assignment, separated by a space between,

The output format:
The first largest m number, maximum number is:
Input the sample:
Given a set of input here, for example:

24 69 June 8, 687-123-5, 78-900
The output sample:
Here is given the corresponding output, for example:

Several of the biggest eighth position, maximum number is: 687

CodePudding user response:

 # include 
# include

# define MAX_SIZE 10

Int main (void)
{
An int array [MAX_SIZE];
Int I, independence idx=0;

For (I=0; I & lt; MAX_SIZE; I++) {
The scanf (" % d ", & amp; Array [I]);
If (array [I] & gt; Array [independence idx])
Independence idx=I;
}


Printf (" No. \ n % d=% d ", independence idx + 1, array [independence idx]);
return 0;
}


For your reference ~

If the array contains multiple identical maximum, then need to special processing, the original poster can try to change ~
  • Related