Advertisement
YasserZ

Triangle Wave!

Feb 22nd, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int freq, amp, t, x = 1;
  6.     cin >> t;
  7.     cout << endl;
  8.     for(int i = 1; i <= t; i++)
  9.     {
  10.         cin >> amp >> freq;
  11.         x = 1;
  12.         while(x <= freq)
  13.         {
  14.  
  15.  
  16.             for(int j = 1; j <= amp; j++)
  17.             {
  18.                 for(int k = 0; k < j; k++)
  19.                     cout << j;
  20.             cout << endl;
  21.             }
  22.             for(int m = amp - 1; m > 0; m--)
  23.             {
  24.                 for(int k = 0; k < m; k++)
  25.                     cout << m;
  26.             cout << endl;
  27.             }
  28.             if(x != freq) //blank line after each wave exept last one
  29.                 cout << endl;
  30.             x++;
  31.  
  32.  
  33.         }
  34.  
  35.         if(i % 2 == 0) //blank line after each 2 cases
  36.             cout << endl;
  37.     }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement