Sorting Problem, sorting
Enter 10 integers in the topic description, sort them in ascending order, and give the position of each element in the original sequence. The input data contains one row, which contains 10 integers separated by spaces. 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 101 2 3 5 4 6 10 7 8 9
# Include <stdio. h> int main () {int I, j, t, m, a [10], B [10] = {1, 2, 4, 5, 6, 7, 8, 9, 10 }, n = 10; for (I = 0; I <n; I ++) scanf ("% d", & a [I]); for (I = 0; I <n-1; I ++) for (j = 0; j <n-i-1; j ++) if (a [j]> a [j + 1]) {t = a [j]; a [j] = a [j + 1]; a [j + 1] = t; m = B [j]; B [j] = B [j + 1]; B [j + 1] = m;} for (I = 0; I <n; I ++) if (I <n-1) printf ("% d", a [I]); elseprintf ("% d", a [I]); printf ("\ n "); for (I = 0; I <n; I ++) {if (I <n-1) printf ("% d", B [I]); elseprintf ("% d \ n", B [I]);} return 0 ;}