Problema: 1042
Enunciado:
Leia 3 valores inteiros e ordene-os em ordem crescente. No final, mostre os valores em ordem crescente, uma linha em branco e em seguida, os valores na sequência como foram lidos.
Linguagem: C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >>c; if (a < b && a < c) { if (b < c) cout << a << endl << b << endl << c << endl; else cout << a << endl << c << endl << b << endl; } if (b < a && b < c) { if (a < c) cout << b << endl << a << endl << c << endl; else cout << b << endl << c << endl << a << endl; } if (c < a && c < b) { if (a < b) cout << c << endl << a << endl << b << endl; else cout << c << endl << b << endl << a << endl; } cout << endl << a << endl << b << endl << c << endl; return 0; } |
Nenhum comentário:
Postar um comentário