Advertisement
mbah_bejo

E Zig P Zag

Oct 23rd, 2020
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int i,j,k,Q,x,y,spasi;
  7.     char tanda;
  8.     cin >>Q ;
  9.     for(i=1; i<=Q;i++)
  10.     {
  11.         cin >> tanda >> x >> y;
  12.         cout <<"Testcase-"<< i << endl;
  13.  
  14.         if (tanda == 'p')
  15.             spasi = 2;
  16.         else
  17.             spasi = 1;
  18.        
  19.         for(j = 0; j<x;j++)
  20.         {  
  21.             if(spasi == 2)
  22.             {
  23.                 if(j%2 == 1) cout << ' ';
  24.             }
  25.             else
  26.                 if(j%2 == 0) cout << ' ';
  27.  
  28.             for(k=0; k<y;k++)
  29.             {
  30.  
  31.                 if(k%2 == 1) cout << '#';
  32.                     else
  33.                 if(k%2 == 0) cout << '*';
  34.             };
  35.            cout << endl;
  36.         }
  37.     }
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement