×
解除綁定,重新設定系統帳號的密碼
您的系統帳號 ID:
您的系統帳號:
您的帳號暱稱:
設定新密碼:
設定新密碼:
×
請輸入要加入的「課程代碼」
請向開設課程的使用者索取「課程代碼」
分類題庫
解題動態
排行榜
討論區
競賽區
登入
註冊
發表新討論
#8052: 分享C++(使用STL)的解法
rosynirvana
(rosynirvana)
學校 : 不指定學校
編號 : 33880
×
傳送站內訊息
傳給:
主題:
內容:
來源 : [182.114.3.244]
最後登入時間 :
2017-07-24 00:02:04
a225.
明明愛排列
| From: [125.45.178.17] | 發表日期: 2013-08-06 12:50
#include <iostream>
#include <algorithm>
#include <vector>
bool comp(int i, int j);
int main()
{
int n;
while(std::cin >> n){
std::vector<int> buf;
for(int i=0; i!=n; ++i){
int temp;
std::cin >> temp;
buf.push_back(temp);
}
std::sort(buf.begin(), buf.end(), comp);
for(std::vector<int>::const_iterator iter = buf.begin(); iter != buf.end(); ++iter)
std::cout << *iter << " ";
std::cout << "\n";
}
return 0;
}
bool comp(int i, int j)
{
if(i % 10 < j % 10)
return true;
if(i % 10 > j % 10)
return false;
if(i / 10 > j / 10)
return true;
return false;
}