Skip to content

Instantly share code, notes, and snippets.

@chomado
Last active August 29, 2015 14:04
Show Gist options
  • Save chomado/2c59e5ce6cdb02847ae5 to your computer and use it in GitHub Desktop.
Save chomado/2c59e5ce6cdb02847ae5 to your computer and use it in GitHub Desktop.
[AOJ] 5つの整数を降順に表示する。問題: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0018
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int input;
vector<int> array;
for (int i=0; i<5; ++i) {
cin >> input;
array.push_back(input);
}
sort(array.begin(), array.end(), greater<int>());
for (vector<int>::size_type i=0; i<array.size(); ++i) {
cout << array[i];
cout << (i==4 ? '\n' : ' ');
}
}
@chomado
Copy link
Author

chomado commented Aug 5, 2014

accepted: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1036765


Sample Input

3 6 9 7 5

Output for the Sample Input

9 7 6 5 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment