Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void uredi(int &a, int &b)
- {
- a = a + b;
- b = -b;
- b = a + b;
- a = a - b;
- }
- int main()
- {
- int a[6];
- int N, K,j;
- bool moze;
- for (int i = 0; i < 6; i++) a[i] = -1000000001;
- cin >> N >> K;
- N--;
- while (N >= 0)
- {
- cin >> a[5];
- moze = true;
- j = 0;
- while (moze)
- {
- moze = false;
- for (int i = 5; i > j; i--)
- {
- if (a[i-1] < a[i])
- {
- uredi(a[i], a[i - 1]);
- moze = true;
- }
- }
- j++;
- }
- N--;
- }
- for (int i = 0; i < K; i++) cout << a[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement