SHARE
TWEET

Untitled

a guest May 21st, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a[10][10];
  8.     cout << "n = ? ( n <= 10 )" << endl; int n; cin >> n;
  9.     cout << "m = ? ( n <= 10 )" << endl; int m; cin >> m;
  10.  
  11.     //Citire
  12.     for (int i =1; i<=n; i++)
  13.     {
  14.         cout << endl;
  15.         for (int j = 1; j<=m; j++)
  16.         {
  17.             cout << "a[" << i << "][" << j << "] = ";
  18.             cin >> a[i][j];
  19.         }
  20.     }
  21.  
  22.     //Afisare
  23.     for (int i =1; i<=n; i++)
  24.     {
  25.         cout << endl;
  26.         for (int j = 1; j<=m; j++)
  27.         {
  28.  
  29.             cout << a[i][j] << " ";
  30.         }
  31.     }
  32.  
  33.  
  34.     int l1,l2,c1,c2;
  35.  
  36.     cout << "l1 = "; cin >> l1;
  37.     cout << "l2 = "; cin >> l2;
  38.  
  39.     for (int j=1; j<=m; j++)
  40.     {
  41.         swap( a[l1][j], a[l2][j]);
  42.     }
  43.  
  44.     cout << "c1 = "; cin >> c1;
  45.     cout << "c2 = "; cin >> c2;
  46.  
  47.     for (int j=1; j<=m; j++)
  48.     {
  49.         swap( a[j][c1], a[j][c2]);
  50.     }
  51.  
  52.     //Afisare
  53.     for (int i =1; i<=n; i++)
  54.     {
  55.         cout << endl;
  56.         for (int j = 1; j<=m; j++)
  57.         {
  58.  
  59.             cout << a[i][j] << " ";
  60.         }
  61.     }
  62. }
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