Problem description enters 10 integers, sorts them from small to large, and gives them the position that appears in the original sequence for each element. Input data has a row, containing 10 integers, separated by a space. Output data has two rows, a sequence after the first behavior, and the position of each element in the original sequence after the second behavior is sorted. Example Input
1 2 3 5 4 6 8 9 10 7
Example Output
1 2 3 4 5 6 7 8 9 101 2 3 5 4 6 10 7 8 9
Hint
#include <stdio.h> #include <stdlib.h>int main () { int a[10], b[10], I, J, temp; for (i=0; i<10; i++) { scanf ("%d", &a[i]); b[i]=a[i];//Save the original array. } For (I=1, i<10; i++) for (j=0; j<10; J + +) { if (a[j]>a[j+1]) { temp=a[j+1]; A[J+1]=A[J]; a[j]=temp; } } for (i=0; i<10; i++) { if (i==0) printf ("%d", A[i]); else printf ("%d", A[i]); } printf ("\ n"); for (i=0; i<10; i++) {for (j=0; j<10; j + +)//based on the saved array, find the original position. { if (B[j]==a[i]) { if (i==0) printf ("%d", j+1); else printf ("%d", j+1);}}}
AC Diary---29--sorting problem