Polnochniy

Untitled

Nov 11th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 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. int min = i;
  17. for (int max = i + 1; max < N; max++)
  18. {
  19. if (a[max] < a[min])
  20. {
  21. min = max;
  22. }
  23. }
  24. swap(a[i], a[min]);
  25. }
  26. cout << "Результат сортировки равен :";
  27. for (int t = 0; t < N; t++)
  28. {
  29. cout << a[t] << " ";
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment