Code:
# include "stdio.h"
Void main ()
{
Void the sort (int a [5]);
Int a [5], I;
Printf (" Enter five characters! \n");
for(i=0; i<5; I++)
The scanf (" % d ", & amp; A [I]);
printf("\n");
Sort (a);
for(i=0; i<5; I++)
Printf (" % d \ t ", a [I]);
}
Void the sort (int a [5])
{
Int k, l, n.
For (l=0; L<4. L++)
{
For (n=l; n<5; N++)
{
If (a [l] & gt; A/n + 1)
K=a, [l].
A [n]=a, [l].
A [l]=k;
}
}
}
Results:
Enter five characters!
12
56
2
45
5
- 858993460-858993460-858993460-858993460-858993460
Press any key to continue
CodePudding user response:
A [n + 1] subscript crossing the lineCodePudding user response:
This is a bubble sort? Look at my one leng one leng ofCodePudding user response:
If you are to use bubble sort, can be written asfor (l=0; L & lt; 5; L++)
{
For (n=0; N & lt; 5 - l - 1; N++)
{
If (a [n] & gt; A/n + 1)
{
K=a, [n].
A [n]=(n + 1), a
A [n + 1]=k;
}
}
}