Asa's Website

C - Swapping Two Numbers

cpaojitp1

最終更新日

Table of Contents

Loading...

問題

https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/3/ITP1_3_C

問題文

x,yx, y を読み込み、小さい順に出力してね。
複数のデータセットで、 x=y=0x = y = 0 が入力されたら終了。

制約

サンプル

I/O 1

3 2 2 2 5 3 0 0
2 3 2 2 3 5

考察

やるだけ。

コード

https://onlinejudge.u-aizu.ac.jp/status/users/a01sa01to/submissions/1/ITP1_3_C/judge/6370433/C++17

int main() { while (true) { int x, y; cin >> x >> y; if (x == 0 && y == 0) break; if (x > y) swap(x, y); printf("%d %d\n", x, y); } return 0; }