Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cout;
- using std::cin;
- using std::endl;
- void main()
- {
- const int size = 20;
- int arr[size];
- for (int i = 0; i < size; i++)
- {
- arr[i] = (rand() % 100);
- cout << arr[i] << "\t";
- }
- for (int i = 0; i < size; i++)
- {
- for (int j = 0; j < size; j++)
- {
- if (arr[j] < arr[j + 1])
- {
- arr[j] = arr[j] + arr[j + 1];
- arr[j + 1] = arr[j] - arr[j + 1];
- arr[j] = arr[j] - arr[j + 1];
- }
- }
- }
- cout << endl << endl;
- for (int i = 0; i < size; i++)
- {
- cout << arr[i] << "\t";
- }
- cout << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement