2016年12月9日 星期五

[UVa]11462 - Age Sort

個人難度評分:★☆☆☆☆
題目在此

這題有點簡單,就不翻譯了
這題我是使用<algorithm> library裡面的sort函式就可以了,據說裡面是內建quik sort

以下為解
//UVa 11462
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    int age[2000001];
    while(cin >> n && n>0){
      for(int i=0; i<n; i++){
        cin >> age[i];
      }
      sort(age,age+n);
      for(int i=0; i<n; i++){
        cout << age[i];
        if(i<n-1){
          cout << ' ';
        }
      }
      cout << endl;
    }
  }

沒有留言:

張貼留言