Advertisement
rootuss

3.25

Dec 28th, 2016
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. cout << "\na) b)" << endl;
  8.  
  9.     int tablica[5][6];
  10.  
  11.     for(int i=0;i<5;i++)
  12.     {
  13.         for(int j=0;j<6;j++)
  14.         {
  15.             tablica[i][j]=i+j;
  16.         }
  17.     }
  18.     for(int i=0;i<5;i++)
  19.     {
  20.         for(int j=0;j<6;j++)
  21.         {
  22.             cout<<tablica[i][j];
  23.         }
  24.         cout<<endl;
  25.     }
  26.  
  27.  
  28. cout << "\nc)" << endl;
  29.  
  30.     for(int i=0;i<5;i++)
  31.     {
  32.             swap(tablica[i][1],tablica[i][2]);
  33.     }
  34.  
  35.  
  36.      for(int i=0;i<5;i++)
  37.     {
  38.         for(int j=0;j<6;j++)
  39.         {
  40.             cout<<tablica[i][j];
  41.         }
  42.         cout<<endl;
  43.     }
  44.  
  45.  
  46. cout << "\nd)" << endl;
  47.  
  48.     int wiersz1, wiersz2;
  49.     cout<<"Podaj wiersze: "<<endl;
  50.     cin>>wiersz1>>wiersz2;     //można dodać komunikat że mają być <=4
  51.     cout<<endl;
  52.  
  53.  
  54.         for(int j=0;j<6;j++)
  55.     {
  56.             swap(tablica[wiersz1][j],tablica[wiersz2][j]);
  57.     }
  58.  
  59.  
  60.      for(int i=0;i<5;i++)
  61.     {
  62.         for(int j=0;j<6;j++)
  63.         {
  64.             cout<<tablica[i][j];
  65.         }
  66.         cout<<endl;
  67.     }
  68.  
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement