# define N 100
Void main (void)
{
Int I=0, j=0, n=0, t=0;
Int a [N].
Printf (" please enter the number of input digital \ n \ r ");
The scanf (" % d ", & amp; N);
Do
{
Printf (" please enter a number: \ n ");
The scanf (" % d ", & amp; A [I]);
i++;
}
While (a [I - 1] & gt;=0);
for(i=1; i
{
T=a, [j].//is produced using the variable tong two value swaps
A [j]=a, a + 1 bonus to [j].
A [m + 1]=t;
}
Printf (" sorted order is: \ n ");
For (I=3; i<=n; I++)
Printf (" % 5 d, "a [I]);
printf("\n");
return 0;
}
This is a matter of the order of the elements in an array output output first character always disappear
Results:
Please input the number of input digital
5
Please enter a number:
5
Please enter a number:
4
Please enter a number:
3
Please enter a number:
2
Please enter a number:
1
After sorting order is:
2, 3, 4,
Press any key to continue
CodePudding user response:
For (I=3; i<=n; Why do you want to start from 3 i++)? Don't start from 0CodePudding user response:
# include
# define N 100
//void main (void)
Int main (void)
{
Int I=0, j=0, n=0, t=0;
Int a [N].
Printf (" please enter the number of input digital \ n \ r ");
The scanf (" % d ", & amp; N);
If # 1
While (I & lt; N) {
Printf (" please enter a number: \ n ");
The scanf (" % d ", & amp; A [I]);
If (a [I] <0)
break;
i++;
}
for (i=0; iFor (j=0; J & lt; N - I - 1; J++)
If (a [j] & gt; + 1 a [j]) {
T=a, [j].
A [j]=a, a + 1 bonus to [j].
A [m + 1]=t;
}
Printf (" sorted order is: \ n ");
for (i=0; iPrintf (" % 5 d, "a [I]);
# the else
/*
Do
{
Printf (" please enter a number: \ n ");
The scanf (" % d ", & amp; A [I]);
i++;
}
While (a [I - 1] & gt;=0);
*/
for(i=1; ithe number of tripsFor (j=1; J If (a [j] & gt; A [m + 1])
{
T=a, [j].//is produced using the variable tong two value swaps
A [j]=a, a + 1 bonus to [j].
A [m + 1]=t;
}
Printf (" sorted order is: \ n ");
For (I=3; i<=n; I++)
Printf (" % 5 d, "a [I]);
# endif
printf("\n");
return 0;
}
For your reference ~
Recommended substitute while the do... While, because if the n input is zero, then what is the result?
Sorting also have a question,
Output also has a problem, compare the code to find their own problems
CodePudding user response:
Programmers to count to start from 0 not 1CodePudding user response: