Advertisement
Polnochniy

Untitled

Nov 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. const int N = 5;
  5. void boo(int *a, int N)
  6. {
  7. for (int i = 0; i < N - 1; i++)
  8. {
  9. int min = i;
  10. for (int max = i + 1; max < N; max++)
  11. {
  12. if (a[max] < a[min])
  13. {
  14. min = max;
  15. }
  16. }
  17. swap(a[i], a[min]);
  18. }
  19. cout << "Результат сортировки равен : ";
  20. }
  21. void vvedite(int *a ,int N )
  22. {
  23. cout << "Введите элементы массива " << endl;
  24. for (int t = 0; t < N; t++)
  25. {
  26. cin >> a[t];
  27. }
  28. }
  29. void rez(int* a ,int N)
  30. {
  31. for (int t = 0; t < N; t++)
  32. {
  33. cout << a[t] << " ";
  34. }
  35. }
  36. int main()
  37. {
  38. setlocale(LC_ALL, "Rus");
  39. int a[N];
  40. vvedite(a, N);
  41. boo(a,N);
  42. rez(a, N);
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement