Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. setlocale(LC_ALL, "Russian");
  7.  
  8. const int SIZE = 5; // размер массива
  9. int a[SIZE];
  10.  
  11. cout << "Введите " << SIZE << " чисел" << endl;
  12. for (int i=0; i<SIZE; i++)
  13. cin >> a[i];
  14.  
  15. // упорядочить по возрастанию
  16. for (int i=0; i<SIZE-1; i++)
  17. for (int j=i+1; j<SIZE; j++)
  18. if (a[j] < a[i])
  19. {
  20. int tmp = a[j];
  21. a[j] = a[i];
  22. a[i] = tmp;
  23. }
  24.  
  25. for (int i=0; i<SIZE; i++)
  26. cout << a[i] << " ";
  27. cout << endl;
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement