488 - Triangle Wave

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

wangluofan
New poster
Posts: 6
Joined: Tue Aug 07, 2012 7:00 pm

Re: 488-Triangle Wave

Post by wangluofan » Thu Aug 16, 2012 12:45 pm

I had submitted this for three times but it still wrong.I'm think there is an error where not discovered.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 488-Triangle Wave

Post by brianfry713 » Thu Aug 16, 2012 11:19 pm

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!

wangluofan
New poster
Posts: 6
Joined: Tue Aug 07, 2012 7:00 pm

Re: 488-Triangle Wave

Post by wangluofan » Fri Aug 17, 2012 2:29 pm

Yes,But I had submitted once and got a wrong,but this time,the code hasn't been changed,this is very strange!!

Sabiha_Fancy
New poster
Posts: 24
Joined: Mon Jul 16, 2012 3:43 pm

Re: 488 - Triangle Wave

Post by Sabiha_Fancy » Sat Sep 08, 2012 12:33 pm

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;
}
Fancy

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 488 - Triangle Wave

Post by brianfry713 » Mon Sep 10, 2012 10:02 pm

Don't print a blank line at the beginning of the output.
Check input and AC output for thousands of problems on uDebug!

atul
New poster
Posts: 7
Joined: Thu Sep 27, 2012 4:21 pm

Re: please help me why i am getting WA for my code ?

Post by atul » Thu Sep 27, 2012 4:27 pm

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;
}

brianfry713
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 ?

Post by brianfry713 » Thu Sep 27, 2012 10:52 pm

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!

atul
New poster
Posts: 7
Joined: Thu Sep 27, 2012 4:21 pm

Re: please help me why i am getting WA for my code ?

Post by atul » Sat Sep 29, 2012 11:20 am

I got AC...
Last edited by atul on Sat Sep 29, 2012 11:50 am, edited 1 time in total.

atul
New poster
Posts: 7
Joined: Thu Sep 27, 2012 4:21 pm

Re: please help me why i am getting WA for my code ?

Post by atul » Sat Sep 29, 2012 11:48 am

Now it is AC..
I forgor to print newline... :D

bimajw
New poster
Posts: 6
Joined: Wed Nov 14, 2012 5:26 am

488(WA) help me..

Post by bimajw » Wed Nov 14, 2012 11:28 am

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";
}
}
}
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 488(WA) help me..

Post by brianfry713 » Thu Nov 15, 2012 1:50 am

Don't double post.
Check input and AC output for thousands of problems on uDebug!

bimajw
New poster
Posts: 6
Joined: Wed Nov 14, 2012 5:26 am

Re: 488(WA) help me..

Post by bimajw » Thu Nov 15, 2012 12:26 pm

sorry I will not repeat again

Sabiha_Fancy
New poster
Posts: 24
Joined: Mon Jul 16, 2012 3:43 pm

Re: 488 - Triangle Wave

Post by Sabiha_Fancy » Sat Dec 08, 2012 9:10 am

Thank you for your reply
Fancy

hansyulian
New poster
Posts: 3
Joined: Sat Dec 22, 2012 1:30 pm

488 WA

Post by hansyulian » Sun Jan 13, 2013 3:00 pm

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;	
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 488 WA

Post by brianfry713 » Sun Jan 13, 2013 8:31 pm

sample output

Code: Select all

1
22
333
22
1

1
22
333
22
1
your output

Code: Select all

1
12
123
12
1

1
12
123
12
1
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 4 (400-499)”