Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- srand(time(NULL));
- const int SIZE = 15;
- int mas[SIZE];
- int buf = 0;
- for (int i = 0; i < SIZE; ++i) {
- mas[i] = rand() % 1000 - 500;
- }
- for (int i = 0; i < SIZE; ++i) {
- cout << mas[i] << " ";
- }
- for (int i = 0; i < SIZE - 1; ++i) {
- for (int j = i+1; j < SIZE; ++j) {
- if (mas[j] < mas[i]){
- buf = mas[j];
- mas[j] = mas[i];
- mas[i] = buf;
- }
- }
- }
- cout << endl;
- for (int i = 0; i < SIZE; ++i) {
- cout << mas[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement