Polnochniy

Untitled

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