Home > Back-end >  C the couple seek counsel
C the couple seek counsel

Time:10-12

Problem: 10 integer input, output will be ordered the 10 integers in ascending order, and odd number before, and even in the latter, for example, if the input number 10:10,9,8,7,6,5,4,3,2,1, output 1 3 5 7 9 2 4 6 8 10.

CodePudding user response:

If (I % 2==1) odd

CodePudding user response:

Don't understand the can make up a complete program let me have a look? Thank you

CodePudding user response:

#include
using namespace std;
As void PaiXu (int * and an int nLen)
{
Int nTemp=0;
For (int I=0; I & lt; NLen; + + I)
{
For (int j=0; J & lt; NLen - 1; + + j)
{
If (as [j] & gt; As [j + 1])
{
NTemp=as [j];
As [j]=as [j + 1);
As [j + 1)=nTemp;
}
}
}
}
As void ShuChu (int * and an int nLen)
{
Int nNum=0;
for (int i=0; I & lt; NLen; + + I)
{
If (as [I] % 2==1)
{
cout}
The else
{
As=[nNum] as [I];
+ + nNum;
}
}
For (int j=0; J & lt; NNum; + + j)
{
cout}
}
Int main ()
{
Int as [10]=,3,6,8,6,1,9,5,2,10 {4};
PaiXu (as, 10);
ShuChu (as, 10);
Return 0;
}
I wrote a simple look at it
  • Related