Home > Back-end >  Input four number since the childhood output
Input four number since the childhood output

Time:11-07

Great god help take a look at me what is wrong here refer (white)

CodePudding user response:

If (a & gt; B) b +=a=b, a=b - a;
If (b & gt; C) c +=b=c, b=c - b;
If (c & gt; D) d +=c -=d, c=d - c;
If (a & gt; B) b +=a=b, a=b - a;
If (b & gt; C) c +=b=c, b=c - b;
If (a & gt; B) b +=a=b, a=b - a;

CodePudding user response:

Number 4 sort or forget it,

CodePudding user response:

reference 1/f, play big shoot early nuclear response:
if (a & gt; B) b +=a=b, a=b - a;
If (b & gt; C) c +=b=c, b=c - b;
If (c & gt; D) d +=c -=d, c=d - c;
If (a & gt; B) b +=a=b, a=b - a;
If (b & gt; C) c +=b=c, b=c - b;
If (a & gt; B) b +=a=b, a=b - a;

The respect to you like a turbulent river

CodePudding user response:

Old is actually the readability is bad, the general picture of the old do not take the readability,

CodePudding user response:

reference 4 floor ooolinux response:
old is actually the readability is bad, old general picture do not take the readability,


Well, I just wrote according to the ideas of the building Lord, actually simple sorting need only 3 lines of code

CodePudding user response:

reference 5 floor early play the play nuclear war response:
Quote: refer to 4th floor ooolinux response:

Old is actually the readability is bad, the general picture of the old do not take the readability,


Well, I just wrote according to the ideas of the building Lord, actually simple sorting need only 3 lines of code


3 rows seems not enough, unless they are written in a line,

CodePudding user response:

Simple bubble, 3 lines can be:
#include

Int main ()
{
Int x [4];

Printf (" input four Numbers: ");
The scanf (" % d, % d, % d, % d ", & amp; X [0], & amp; X [1], & amp; X [2], & amp; X [3]);
For (int I=3; I & gt; 0; I -)
For (int j=0, k; J & lt; i; J++)
If (x [j] & gt; [j x + 1]), k=x [j], [j] x=x + 1] [j, x [m + 1]=k;
Printf (" % d % d % d % d \ n ", [0], x x [1], [2] x, x [3]).

return 0;
}

The key is two Numbers with a comma expression exchange can be written on one line

CodePudding user response:

refer to 7th floor early play big play nuclear war reply:
simple bubble, 3 lines can be:
#include

Int main ()
{
Int x [4];

Printf (" input four Numbers: ");
The scanf (" % d, % d, % d, % d ", & amp; X [0], & amp; X [1], & amp; X [2], & amp; X [3]);
For (int I=3; I & gt; 0; I -)
For (int j=0, k; J & lt; i; J++)
If (x [j] & gt; [j x + 1]), k=x [j], [j] x=x + 1] [j, x [m + 1]=k;
Printf (" % d % d % d % d \ n ", [0], x x [1], [2] x, x [3]).

return 0;
}

The key lies in two Numbers with a comma expression exchange can be written on one line


Call the STL sort can also,
  • Related