1305:整数排序

来源:互联网 发布:mac怎么搜索硬盘文件 编辑:程序博客网 时间:2024/05/21 12:48

1305:整数排序


Description


给出10个整数a(i)(0<=ai<=1000)

输出排序好之后的序列。


Input


输入为一行,包含10个无规则的整数,用空额分割。


Output

按照从小到大排序后的十个整数。


Sample Input


9  8  6  2  1  5  0  3  4  7


Sample Output


0  1  2  3  4  5  6  7  8  9


Source


安科第一届新生ACM赛


#include<iostream>using namespace std;int main(){    int a[10],i,index,temp,j;    for(i=0;i<10;i++)        cin>>a[i];    for(i=0;i<9;i++)    {        index=i;        for(j=i+1;j<10;j++)        {            if(a[j]<a[index])                index=j;        }            if(i!=index)            {                temp=a[i];a[i]=a[index];a[index]=temp;            }    }cout<<a[0];for(i=1;i<10;i++)    cout<<" "<<a[i];return 0;}