SHARE
TWEET

d

a guest Oct 15th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int M[100][120], n, m, aux;
  5.  
  6. int i, j, k;
  7.  
  8. void citire()
  9. {
  10.     cin >> n >> m;
  11.     for(i = 0; i < n; i++)
  12.         for(j = 0; j < m; j++)
  13.             cin >> M[i][j];
  14. }
  15.  
  16. void sortare()
  17. {
  18.     for(k = 0; k < n; k++)
  19.         for(i = 0; i < n; i += 2)
  20.             for(j = 0; j < m - 1; j++)
  21.             {
  22.                 if(M[i][j] > M[i][j + 1])
  23.                 {
  24.                     aux = M[i][j];
  25.                     M[i][j] = M[i][j + 1];
  26.                     M[i][j + 1] = aux;
  27.                 }
  28.             }
  29. }
  30.  
  31. void afisare()
  32. {
  33.     for(i = 0; i < n; i += 2)
  34.     {
  35.         for(j = 0; j < m; j++)
  36.             cout << M[i][j] << " ";
  37.         cout << endl;
  38.     }
  39. }
  40.  
  41. int main()
  42. {
  43.     citire();
  44.     sortare();
  45.     afisare();
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top