UVA online JUDGE
PROBLEM:488
(TRIANGLE WAVE)
Solution:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int m,i,j,freq,ampl,t,k;
scanf("%d",&t);
for(m=0; m<t; m++)
{ if(m!=0) puts("");
scanf("%d%d",&l,&freq);
for(k=0; k<freq; k++)
{ if(k!=0) puts("");
for(i=0; i<ampl; i++)
{
for(j=0; j<=i; j++)
{
printf("%d",i+1);
}
printf("\n");
}
for(i=ampl; i>1; i--)
{
for(j=i-1; j>0; j--)
{
printf("%d",i-1);
}
printf("\n");
}
}
}
return 0;
}
2. NOTE:
/* if yoy use puts("") it works as printf.
But it gives an extra newline after printing the line.
It means puts("") gives you an extra '\n' after the line,
that you have written inside the quotation mark;
If you don't write any line inside the quotation mark,
it will give you nothing but a new line or '\n'*/
//Language:C++
No comments:
Post a Comment