anon20016

6

Dec 12th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <vector>
  3. #include <iostream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int n, m;
  11. cin >> n >> m;
  12. int a[100][100];
  13. for (int i = 0; i < n; i++) {
  14. for (int j = 0; j < m; j++) {
  15. cin >> a[i][j];
  16. }
  17. }
  18. for (int i = 0; i < n; i++) {
  19. int mn = 0;
  20. for (int j = 0; j < m; j++) {
  21. if (a[i][j] < a[i][mn]) {
  22. mn = j;
  23. }
  24. }
  25. int t = a[i][0];
  26. a[i][0] = a[i][mn];
  27. a[i][mn] = t;
  28. }
  29.  
  30. for (int i = 0; i < n; i++) {
  31. for (int j = 0; j < m; j++) {
  32. cout << a[i][j] << ' ';
  33. }
  34. cout << endl;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment