488 - Triangle Wave
Moderator: Board moderators
-
- New poster
- Posts: 6
- Joined: Tue Aug 07, 2012 7:00 pm
Re: 488-Triangle Wave
I had submitted this for three times but it still wrong.I'm think there is an error where not discovered.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 488-Triangle Wave
If you copy and paste the code you've posted in this thread and submit it, the result is AC.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 6
- Joined: Tue Aug 07, 2012 7:00 pm
Re: 488-Triangle Wave
Yes,But I had submitted once and got a wrong,but this time,the code hasn't been changed,this is very strange!!
-
- New poster
- Posts: 24
- Joined: Mon Jul 16, 2012 3:43 pm
Re: 488 - Triangle Wave
I am getting wrong answere each time i submit it. I can't find the error.
Please help me
#include<stdio.h>
int main()
{
int n,f,a,i,j,k,l,m;
scanf("%d",&n);
printf("\n");
for(i=0; i<n; ++i)
{
scanf("%d %d",&a,&f);
if(a==0 || f==0)
{
printf("0\n");
if(i<n-1)
printf("\n");
continue;
}
if(i>0)
printf("\n");
for(j=0; j<f; ++j)
{
m=1;
for(k=1; k<=(2*a-1); ++k)
{
if(k<=a)
{
for(l=1; l<=k; ++l)
{
printf("%d",k);
}
}
else
{
for(l=1; l<=k-(2*m); ++l)
{
printf("%d",k-(2*m));
}
m++;
}
printf("\n");
}
if(j<f-1)
printf("\n");
}
if(i<n-1)
printf("\n");
}
return 0;
}
Please help me
Code: Select all
int main()
{
int n,f,a,i,j,k,l,m;
scanf("%d",&n);
printf("\n");
for(i=0; i<n; ++i)
{
scanf("%d %d",&a,&f);
if(a==0 || f==0)
{
printf("0\n");
if(i<n-1)
printf("\n");
continue;
}
if(i>0)
printf("\n");
for(j=0; j<f; ++j)
{
m=1;
for(k=1; k<=(2*a-1); ++k)
{
if(k<=a)
{
for(l=1; l<=k; ++l)
{
printf("%d",k);
}
}
else
{
for(l=1; l<=k-(2*m); ++l)
{
printf("%d",k-(2*m));
}
m++;
}
printf("\n");
}
if(j<f-1)
printf("\n");
}
if(i<n-1)
printf("\n");
}
return 0;
}
Fancy
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 488 - Triangle Wave
Don't print a blank line at the beginning of the output.
Check input and AC output for thousands of problems on uDebug!
Re: please help me why i am getting WA for my code ?
Please help me ,,Getting wrong ans..problem no. 488 ..Triangle wave
here is my code
#include <iostream>
using namespace std;
int main()
{
int amp,fre,i,n,j,v,b;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>amp>>fre;
for(j=1;j<=fre;j++)
{
for(int k=1;k<=amp;k++)
{
for(int l=1;l<=k;l++)
cout<<k;
cout<<"\n";
}
for(v=amp-1;v>=1;v--)
{
for(b=1;b<=v;b++)
cout<<v;
cout<<"\n";
}
cout<<"\n";
}
}
return 0;
}
here is my code
#include <iostream>
using namespace std;
int main()
{
int amp,fre,i,n,j,v,b;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>amp>>fre;
for(j=1;j<=fre;j++)
{
for(int k=1;k<=amp;k++)
{
for(int l=1;l<=k;l++)
cout<<k;
cout<<"\n";
}
for(v=amp-1;v>=1;v--)
{
for(b=1;b<=v;b++)
cout<<v;
cout<<"\n";
}
cout<<"\n";
}
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: please help me why i am getting WA for my code ?
NOTE: There is a blank line after each separate waveform, excluding the last one.
Check input and AC output for thousands of problems on uDebug!
Re: please help me why i am getting WA for my code ?
I got AC...
Last edited by atul on Sat Sep 29, 2012 11:50 am, edited 1 time in total.
Re: please help me why i am getting WA for my code ?
Now it is AC..
I forgor to print newline...
I forgor to print newline...

488(WA) help me..
my code.
#include <iostream>
using namespace std;
int main(){
int T,A,f,i,j,k,l;
cin>>T;
cout<<"\n";
for(i=1;i<=T;i++){
cin>>A>>f;
if(A>9){break;}
if(A>0&&A<=9){
cout<<"\n";
for(j=1;j<=f;j++){
for(k=1;k<=A;k++){
for(l=1;l<=k;l++){
cout<<k;
}
cout<<"\n";
}
for(k=A-1;k>=1;k--){
for(l=1;l<=k;l++){
cout<<k;
}
cout<<"\n";
}
cout<<"\n";
}
}
}
}
#include <iostream>
using namespace std;
int main(){
int T,A,f,i,j,k,l;
cin>>T;
cout<<"\n";
for(i=1;i<=T;i++){
cin>>A>>f;
if(A>9){break;}
if(A>0&&A<=9){
cout<<"\n";
for(j=1;j<=f;j++){
for(k=1;k<=A;k++){
for(l=1;l<=k;l++){
cout<<k;
}
cout<<"\n";
}
for(k=A-1;k>=1;k--){
for(l=1;l<=k;l++){
cout<<k;
}
cout<<"\n";
}
cout<<"\n";
}
}
}
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 488(WA) help me..
Don't double post.
Check input and AC output for thousands of problems on uDebug!
Re: 488(WA) help me..
sorry I will not repeat again
-
- New poster
- Posts: 24
- Joined: Mon Jul 16, 2012 3:43 pm
-
- New poster
- Posts: 3
- Joined: Sat Dec 22, 2012 1:30 pm
488 WA
what is wrong with my code?
Code: Select all
#include <cstdio>
int main()
{
long n;
scanf("%ld",&n);
for (long i = 0; i < n; i++)
{
if (i != 0) printf("\n");
long a, f;
scanf("%ld%ld",&a,&f);
for (long j = 0; j < f; j++)
{
if (j != 0) printf("\n");
for (long k = 1; k <= a; k++)
{
for (long l = 0; l < k; l++)
printf("%ld",l+1);
printf("\n");
}
for (long k = a-1; k >= 1; k--)
{
for (long l = 0; l < k; l++)
printf("%ld",l+1);
printf("\n");
}
}
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 488 WA
sample outputyour output
Code: Select all
1
22
333
22
1
1
22
333
22
1
Code: Select all
1
12
123
12
1
1
12
123
12
1
Check input and AC output for thousands of problems on uDebug!