Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int k,w, kolumny, wiersze;
  8.  
  9.     cout << "ilosc kolumn" << endl;
  10.     cin >> kolumny;
  11.     cout << "ilosc wierszy" << endl;
  12.     cin >> wiersze;
  13.  
  14.    for (w=0;w<wiersze;w++)
  15.     {
  16.         if (w % 2 == 0)
  17.         {
  18.             for (k=0;k<kolumny;k++)
  19.                cout <<"x";
  20.         }
  21.             else
  22.         {
  23.             for (k=0;k<kolumny;k++)
  24.                 cout <<".";
  25.         }
  26.  
  27.         cout <<endl;
  28.    }
  29.  
  30.     //DRUGIE ZADANIE
  31.  
  32.  for (w=0;w<wiersze;w++)
  33.     {
  34.         for (k=0;k<kolumny;k++)
  35.         {
  36.             if (k % 2 == 0)
  37.                 cout <<"x";
  38.  
  39.             else cout <<".";
  40.         }
  41.         cout <<endl;
  42.    }
  43.  
  44. //TRZECIE
  45.  
  46.  
  47.  for (w=wiersze;w>0;w--)
  48.     {
  49.         for (k=kolumny;k>w;k--)
  50.             cout <<".";
  51.         for (k=w;k>0;k--)
  52.             cout <<"x";          
  53.  
  54.         cout <<endl;
  55.     }
  56.  
  57.  
  58.     // CZWARTE
  59.  
  60.     for (w=0; w<=(wiersze/2);w++)
  61.     {
  62.         for (k=0;k<w;k++)
  63.             cout << ".";
  64.         for (k=(kolumny-w);k>w;k--)
  65.             cout << "x";
  66.         for (k=0;k<w;k++)
  67.             cout << ".";
  68.         cout << endl;
  69.     }
  70.     --k;
  71.     int temp = 1;
  72.     for (w=0; w<(wiersze/2)-1;w++)    {        
  73.         ++temp;
  74.         for (int j=k-w;j>0;j--)
  75.             cout << ".";
  76.         for (int j=0;j<=w+temp;j++)
  77.             cout << "x";
  78.         for (int j=k-w;j>0;j--)
  79.             cout << ".";
  80.         cout << endl;
  81.     }
  82.  
  83.     //PIĄTE
  84.  
  85.      for(w=0;w<wiersze;w++)
  86.     {
  87.         for(k=0;k<kolumny;k++ )
  88.         {
  89.             if((w+k)%2==0)
  90.                 cout <<"x";
  91.             else cout <<".";
  92.         }
  93.  
  94.         cout << endl;
  95.     }
  96.  
  97.  
  98.     return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement