vertc

10-10

Oct 10th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int main () {
  8.     int i, j,a ;
  9.     int wybor;
  10.     int tab[3][5];
  11.     srand(time(0));
  12.         cout<<"1. Wypelnienie tablicy dwuwymiarowej losowymi liczbami."<<endl;
  13.         cout<<"2. Wypelnienie tablicy dwuwymiarowej wpisujac recznie."<<endl;
  14.         cout<<"3. Wyjscie z programu."<<endl;
  15.         cout<<endl<<"Wybierz dzialanie: ";
  16.         cin>>wybor;
  17.    
  18.     switch (wybor) {
  19.         case 1:
  20.             for(int i=0;i<3;i++) {
  21.                 for(int j=0;j<5;j++) {
  22.                     tab[i][j] = rand()%10;
  23.                 }
  24.             }
  25.             for(int i=0;i<3;i++) {
  26.                 cout<<" "<<endl;
  27.                 for(int j=0;j<5;j++) {
  28.                     cout<<tab[i][j];
  29.                     }
  30.                 }
  31.             break;
  32.         case 2:
  33.             for(int i=0;i<3;i++)
  34.                 for(int j=0;j<5;j++) {
  35.                     cout<<"Podaj wartosc do tablicy: ";
  36.                     cin>>a;
  37.                     tab[i][j] = a;
  38.                 }
  39.             for(int i=0;i<3;i++) {
  40.                 cout<<" "<<endl;
  41.                 for(int j=0;j<5;j++) {
  42.                     cout<<tab[i][j];
  43.                     }
  44.                 }
  45.             break;
  46.         case 3:
  47.                 cout<<endl<<"Wychodzenie z programu...";
  48.             break;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment