排序问题

Description

输入10个整数,将它们从小到大排序后输出,并给出现在每个元素在原来序列中的位置。

Input

输入数据有一行,包含10个整数,用空格分开。

Output

输出数据有两行,第一行为排序后的序列,第二行为排序后各个元素在原来序列中的位置。

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

HINT

#include
using namespace std;
int main()
{
 int a[4][15];
 int i,n,m=0,p;
 for(i=0;i<10;i++)
  cin>>a[0][i];
 for(i=0;i<10;i++)
 { for(n=0;n<10;n++)
 {if(n!=i)
   if(a[0][i]>a[0][n])
    m++;
 }
 p=a[0][i];
 a[2][m]=p;
 a[3][m]=i+1;
 m=0;
 }
 for(i=2;i<4;i++)
 {for(n=0;n<10;n++)
  {p=a[i][n];
      cout<<p;
  if(n!=9)
   cout<<' ';
  }
  cout<<endl;
 }
 
 return 0;
}
原文地址:https://www.cnblogs.com/oversea201405/p/3767071.html