
This is output to the input of the number of five largest number, the result is very strange,,, it would put the following that I <=6 of 6 as a digital input (such as if the input 1 2 3 4 5, there will be a Max=6),
Why is this excuse me?
# include & lt; Stdio. H>
Int main (void)
{
Int a, [5].
Printf (" please enter 5 Numbers: \ n ");
for(int i=1; i<=5; I++)
{
The scanf (" % d ", & amp; A [I]);
}
Int I, temp;
For (I=2; i<=6; I++)
{
If (a [I - 1] & gt;=a [I])
{
Printf (" % d & gt; % d ", a [I - 1], a [I]);
Temp=a, [I - 1].
A [I]=temp;
}
}
Printf (" Max=% d ", a [I]);
}
The bow for you

CodePudding user response:
Who is going to help me
CodePudding user response:
For (I=2; I & lt;=6; I++) here, when I=6, an array of a [6] subscript crossing the line, the value of a [6] is random, just got 6,CodePudding user response:
Instead I & lt; 6, right,CodePudding user response:
As a common sense, starting from 0 C language array subscriptsDefined as the array of int a [5], their legal element is
A [0] a [1] a [2] a [3] a [4]
CodePudding user response:
So that is what it boils down to.But change once, again meet a problem, is that when there are both positive and negative Numbers in the input values, the result output Max=0
Be able to answer it for me?
CodePudding user response: