[Plain] Description
Input 10 Integers of different sizes, sort them in ascending order, and then output them to the positions where each element is located in the original sequence.
Input
The input data contains a row containing 10 integers separated by spaces.
Output
The output data has two rows. The first row is the sorted sequence, and the second row is the position of each element in the original sequence.
Sample Input
1 2 3 5 4 6 8 9 10 7
Sample Output
1 2 3 4 5 6 7 8 9 10
1 2 3 5 4 6 10 7 8 9
Description
Input 10 Integers of different sizes, sort them in ascending order, and then output them to the positions where each element is located in the original sequence.
Input
The input data contains a row containing 10 integers separated by spaces.
Output
The output data has two rows. The first row is the sorted sequence, and the second row is the position of each element in the original sequence.
Sample Input
1 2 3 5 4 6 8 9 10 7
Sample Output
1 2 3 4 5 6 7 8 9 10
1 2 3 5 4 6 10 7 8 9
[Plain] # include <stdio. h>
Int main ()
{
Int I;
Int j;
Int t;
Int flag;
Int a [10];
Int B [10];
For (I = 0; I <10; I ++)
{
Scanf ("% d", & a [I]);
}
For (I = 0; I <10; I ++)
{
B [I] = a [I];
}
For (I = 0; I <9; I ++)
{
For (j = I + 1; j <10; j ++)
{
If (a [I]> a [j])
{
T = a [I];
A [I] = a [j];
A [j] = t;
}
}
}
For (I = 0; I <10; I ++)
{
Printf ("% d", a [I]);
If (I <9)
{
Printf ("");
}
Else
{
Printf ("\ n ");
}
}
For (I = 0; I <10; I ++)
{
Flag = 0;
For (j = 0; j <10; j ++)
{
If (a [I] = B [j])
{
Flag = 1;
Printf ("% d", j + 1 );
If (I <9)
{
Printf ("");
}
}
If (flag)
{
Break;
}
}
}
Return 0;
}
# Include <stdio. h>
Int main ()
{
Int I;
Int j;
Int t;
Int flag;
Int a [10];
Int B [10];
For (I = 0; I <10; I ++)
{
Scanf ("% d", & a [I]);
}
For (I = 0; I <10; I ++)
{
B [I] = a [I];
}
For (I = 0; I <9; I ++)
{
For (j = I + 1; j <10; j ++)
{
If (a [I]> a [j])
{
T = a [I];
A [I] = a [j];
A [j] = t;
}
}
}
For (I = 0; I <10; I ++)
{
Printf ("% d", a [I]);
If (I <9)
{
Printf ("");
}
Else
{
Printf ("\ n ");
}
}
For (I = 0; I <10; I ++)
{
Flag = 0;
For (j = 0; j <10; j ++)
{
If (a [I] = B [j])
{
Flag = 1;
Printf ("% d", j + 1 );
If (I <9)
{
Printf ("");
}
}
If (flag)
{
Break;
}
}
}
Return 0;
}