1. The positive sequence output (output is 1 2 3 4 5 6 7 8)
# include & lt; Stdio. H>
Void main ()
{
Int I, j, temp.
Int a [8]=,4,7,8,6,3,5,2 {1};
For (j=0; J<8-1; J++)
For (I=0; i<8 - j - 1; I++)
{
If (a [I] {temp=a, [I].
A [I]=a, [I + 1].
A=\ [I + 1];
}
}
for(i=0; i<8; I++)
{
Printf (" % d ", a [I]);
}
Printf (" \ n ");
}
2. Reverse output (output of 8 7 June 5 4 3 2 1)
# include & lt; Stdio. H>
Void main ()
{
Int I, j, temp.
Int a [8]=,4,7,8,6,3,5,2 {1};
For (j=0; J<8-1; J++)
For (I=0; i<8 - j - 1; I++)
{
If (a [I] & gt; A [I + 1])
{temp=a, [I].
A [I]=a, [I + 1].
A=\ [I + 1];
}
}
for(i=0; i<8; I++)
{
Printf (" % d ", a [I]);
}
Printf (" \ n ");
}
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html