#45715: sort真好用


yp11351280@yphs.tp.edu.tw (810-43韓睿哲)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [203.72.178.1]
最後登入時間 :
2025-10-07 16:36:49

PS:sort的用法(陣列):int c[n]; sort(c,c+n);(由小到大)

#include<iostream>
#include<algorithm> 
using namespace std;
int main(){
    int n;
    while(cin>>n&&n!=0){
        int c[n];
        for(int j=0;j<n;j++){
            cin>>c[j];
        }
        sort(c,c+n);
        for(int g=0;g<n;g++) cout<<c[g]<<" ";
        cout<<endl;
    }