Polnochniy

Untitled

Nov 11th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. const int N = 5;
  5. int main()
  6. {
  7. setlocale(LC_ALL, "Rus");
  8. int a[N];
  9. cout << "Введите элементы массива " << endl;
  10. for (int t = 0; t < N; t++)
  11. {
  12. cin >> a[t];
  13. }
  14. for (int i = 0; i < N - 1; i++)
  15. {
  16. for (int j = i + 1; j < N; j++)
  17. {
  18. if (a[i] > a[j])
  19. {
  20. swap(a[i], a[j]);
  21. }
  22. }
  23. }
  24. cout << " Результат сортировки равен: ";
  25. for (int t = 0; t < N; t++)
  26. cout << a[t] << " ";
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment