hdu 2016 数据的交换输出
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 54747    Accepted Submission(s): 20795

Problem Description

Input

Output

Sample Input
4 2 1 3 4
5 5 4 3 2 1
0

Sample Output
1 2 3 4
1 4 3 2 5

/*题解：
水过

*/

`#include<cstdio>#include<algorithm>using namespace std;int main(){    int i,n,mark,a[110],b[110];    while(scanf("%d",&n),n)    {        for(i=0; i<n; i++)        {            scanf("%d",&a[i]);            b[i]=a[i];        }        sort(a,a+n);        for(i=0; i<n; i++)        {            if(a[0]==b[i])            {                mark=i;                break;            }        }        for(i=0; i<n; i++)        {            if(i==0)            printf("%d ",a[0]);            else if(i==mark&&mark!=n-1)            printf("%d ",b[0]);            else if(i==mark&&mark==n-1)            printf("%d\n",b[0]);            else if(i!=n-1) printf("%d ",b[i]);            else printf("%d\n",b[i]);        }     }    return 0;}`