A - Permute to Maximize 解説 by en_translator
If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).
You need to receive three integers as input, sort it in descending order, and print them in that order. The operation of rearranging integers in ascending or descending order is called sort; as in sample code below (C++ and Python), in most languages sorting can be done by simply calling a predefined function. Still, in this problem we can stick to simple conditional branches because we are just asked to sort three integers.
Sample code (C++):
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
vector<int> v = {a, b, c};
sort(v.begin(), v.end());
cout << v[2] << v[1] << v[0] << endl;
}
Sample code (Python) :
a, b, c = input().split()
v = sorted([a, b, c])
print(v[2] + v[1] + v[0])
投稿日時:
最終更新: