Advertisement
B3ar6

zadanie 2 - pętle i warunki zagnieżdżone

Apr 6th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int m, n, wyb, pp;
  7.     cout << "Podaj, ile wierszy ma miec ksztalt: ";
  8.     cin >> m;
  9.     cout << "Podaj, ile kolumn ma miec ksztalt: ";
  10.     cin >> n;
  11.     cout << endl;
  12.    
  13.    
  14.     cout << "Wybierz symbol, ktorym chcesz narysowac prostokat: " << endl;
  15.     cout << "1. wykorzystaj symbol | " << endl;
  16.     cout << "2. wykorzystaj symbol + " << endl;
  17.     cout << "3. wykorzystaj symbol - " << endl;
  18.     cout << "4. wykorzystaj symbole a&b naprzemiennie " << endl;
  19.     cin >> wyb;
  20.     cout << endl;
  21.    
  22.    
  23.     cout << "Wybierz, czy prostokat ma byc pelen, czy pusty: " << endl;
  24.     cout << "1. prostokat pusty" << endl;
  25.     cout << "2. prostokat pelny" << endl;
  26.     cin >> pp;
  27.     cout << endl;
  28.    
  29.     switch(pp)
  30.     {
  31.         case 1:
  32.         {
  33.             if(wyb==1)
  34.             {
  35.                 for(int i=1;i<=m; i++)
  36.                 {
  37.                     if(i==1 || i==m)
  38.                     {
  39.                         for(int i=1; i<=n; i++)
  40.                         {
  41.                             cout << "|";
  42.                         }
  43.                     }
  44.                     else
  45.                     {
  46.                         for(int i=1; i<=n; i++)
  47.                         {
  48.                             if(i==1 || i==n)
  49.                                 cout << "|";
  50.                             else
  51.                                 cout << " ";
  52.                         }
  53.                     }
  54.                 cout << endl;
  55.                 }
  56.             }
  57.             else if(wyb==2)
  58.             {
  59.                 for(int i=1;i<=m; i++)
  60.                 {
  61.                     if(i==1 || i==m)
  62.                     {
  63.                         for(int i=1; i<=n; i++)
  64.                         {
  65.                             cout << "+";
  66.                         }
  67.                     }
  68.                     else
  69.                     {
  70.                         for(int i=1; i<=n; i++)
  71.                         {
  72.                             if(i==1 || i==n)
  73.                                 cout << "+";
  74.                             else
  75.                                 cout << " ";
  76.                         }
  77.                     }
  78.                 cout << endl;
  79.                 }
  80.             }
  81.             else if(wyb==3)
  82.             {
  83.                 for(int i=1;i<=m; i++)
  84.                 {
  85.                     if(i==1 || i==m)
  86.                     {
  87.                         for(int i=1; i<=n; i++)
  88.                         {
  89.                             cout << "-";
  90.                         }
  91.                     }
  92.                     else
  93.                     {
  94.                         for(int i=1; i<=n; i++)
  95.                         {
  96.                             if(i==1 || i==n)
  97.                                 cout << "-";
  98.                             else
  99.                                 cout << " ";
  100.                         }
  101.                     }
  102.                 cout << endl;
  103.                 }
  104.             }
  105.             else if(wyb==4)
  106.                 {
  107.                 for(int i=1;i<=m; i++)
  108.                 {
  109.                     if(i==1 || i==m)
  110.                     {
  111.                         for(int i=1; i<=n; i++)
  112.                         {
  113.                             if(i%2==1)
  114.                                 cout << "a";
  115.                             else
  116.                                 cout << "b";
  117.                         }
  118.                     }
  119.                     else
  120.                     {
  121.                         for(int i=1; i<=n; i++)
  122.                         {
  123.                             if(i==1 || i==n)
  124.                             {
  125.                                 if(i%2==1)
  126.                                     cout << "a";
  127.                                 else
  128.                                     cout << "b";
  129.                             }
  130.                             else
  131.                                 cout << " ";
  132.                                
  133.                         }
  134.                     }
  135.                 cout << endl;
  136.                 }
  137.             }
  138.         break;
  139.        
  140.         default:
  141.         break;
  142.         }
  143.     }
  144.    
  145.     system("Pause");
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement