Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4.  
  5. {
  6. setlocale(LC_ALL, "Russian");
  7. int n;
  8. int a[5];
  9. for (int i = 0; i < 5; i++)
  10. {
  11. cout << "Введите число ";
  12. cin >> a[i];
  13. }
  14. if (a[0] > a[1]) {
  15. n = a[0], a[0] = a[1], a[1] = n;
  16. }
  17. if (a[1] > a[2]) {
  18. n = a[1], a[1] = a[2], a[2] = n;
  19. }
  20. if (a[2] > a[3]) {
  21. n = a[2], a[2] = a[3], a[3] = n;
  22. }
  23. if (a[3] > a[4]) {
  24. n = a[3], a[3] = a[4], a[4] = n;
  25. }
  26.  
  27. //for (int i = 0; i < 5; i++) {
  28. // cout << " " << a[i];
  29. //}
  30. if (a[0] > a[1]) {
  31. n = a[0], a[0] = a[1], a[1] = n;
  32. }
  33.  
  34. if (a[1] > a[2]) {
  35. n = a[1], a[1] = a[2], a[2] = n;
  36. }
  37. if (a[2] > a[3]) {
  38. n = a[2], a[2] = a[3], a[3] = n;
  39. }
  40.  
  41.  
  42.  
  43. for (int i = 0; i < 5; i++) {
  44. cout << " " << a[i];
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement