排序

来源:互联网 发布:淘宝客鹊桥活动玩法 编辑:程序博客网 时间:2024/06/08 20:06

Problem Description
给你N(N<=100)个数,请你按照从小到大的顺序输出。
Input
输入数据第一行是一个正整数N,第二行有N个整数。
Output
输出一行,从小到大输出这N个数,中间用空格隔开。
Example Input
5
1 4 3 2 5
Example Output
1 2 3 4 5

#include <iostream>#include <math.h>#include <cstdio>#include <cstring>#include <algorithm>//sort函数在这里面using namespace std;int a[10010];int b[10010];int main(){    int n;    cin>>n;    for(int i = 0; i < n; i++)    {        cin>>a[i];    }    sort(a, a+n);    for(int i = 0; i < n; i++)    {        if(i == 0)            cout<<a[0];        else            cout<<" "<<a[i];    }    cout<<endl;    return 0;}