7/25/2013

488 - Triangle Wave - UVA

  1. #include<iostream>
  2. using namespace std;
  3. void printWave(int amplitude)
  4. {
  5.         for(int i = 1; i <= amplitude; i++){
  6.                 for(int ii = 1; ii <= i; ii++){
  7.                         cout<<i;
  8.                 }
  9.                 cout<<endl;
  10.         }
  11.         for(int j = amplitude-1; j >= 1; j--){
  12.                 for(int jj = 1; jj<=; jj++){
  13.                         cout<<j;
  14.                 }
  15.                 cout<<endl;
  16.         }
  17. }
  18. int main ()
  19. {
  20.         int cases , amp , freq;
  21.         cin>>cases;
  22.         for(int i=0 ; i<cases ; i++){
  23.                 if(i>0) cout<<endl;
  24.                 cin>>amp>>freq;
  25.                 for(int j=0 ; j<freq; j++){
  26.                         if(j>0)cout<<endl;
  27.                         printWave(amp);
  28.                 }
  29.         }
  30.         return 0;
  31. }


    You can find more of my solutions on
     Here

No comments:

Post a Comment