Page 17 of 19
Re: 488 - Triangle Wave
Posted: Thu Jan 31, 2013 9:00 pm
by Dendesha
I don't know why am I getting wrong answer can any one help?
Code: Select all
#include<stdio.h>
int main()
{
int t,n,f;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&f);
for(int l=0;l<f;l++)
{
for(int j=1;j<=n;j++)
{
for(int k=0;k<j;k++)
{
printf("%d",j);
}
printf("\n");
}
for(int m=n-1;m>0;m--)
{
for(int h=0;h<m;h++)
{
printf("%d",m);
}
printf("\n");
}
if(l<f-1)
{
printf("\n");
}
}
}
return 0;
}
Re: 488 - Triangle Wave
Posted: Fri Feb 01, 2013 9:44 pm
by brianfry713
Input:
AC output:
Code: Select all
1
22
333
22
1
1
22
333
22
1
1
22
333
4444
333
22
1
Re: 488 - PRESENTATION ERROR!
Posted: Fri Mar 15, 2013 5:50 pm
by omarking06
Whats wrong with this code please !!! .. i checked the I/O !! and nothing !!
I got WA!
Code: Select all
#include <iostream>
using namespace std;
int main()
{
int t,a,f;
cin>>t;
for (int i=0;i<t;i++)
{
cin>>a>>f;
for (int i=0;i<f;i++)
{
for (int j=1;j<=a;j++)
{
cout<<j;
for (int k=1;k<j;k++)
{
cout<<j;
}
cout<<endl;
}
for (int x=a-1;x>0;x--)
{
cout<<x;
for (int y=x;y>1;y--)
{
cout<<x;
}
cout<<endl;
}
if (i==f-1) continue;
cout<<endl;
}
}
}
Re: 488 - PRESENTATION ERROR!
Posted: Fri Mar 15, 2013 9:11 pm
by brianfry713
Input:
Correct output:
Code: Select all
1
22
333
22
1
1
22
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
Re: 488 - PRESENTATION ERROR!
Posted: Sat Mar 16, 2013 2:01 am
by omarking06
here is my I/O :
Code: Select all
2
3
2
1
22
333
22
1
1
22
333
22
1
4
3
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
i dont see anything wrong !!
Re: 488 - PRESENTATION ERROR!
Posted: Sat Mar 16, 2013 7:30 am
by omarking06
Plz Help !
488 - Triangle Wave
Posted: Sat Mar 16, 2013 4:45 pm
by omarking06
I really dont know whats wrong with my code !?
I got WA!!!
Code: Select all
#include <iostream>
using namespace std;
int main()
{
int t,a,f;
cin>>t;
for (int i=0;i<t;i++)
{
cin>>a>>f;
for (int i=0;i<f;i++)
{
for (int j=1;j<=a;j++)
{
cout<<j;
for (int k=1;k<j;k++)
{
cout<<j;
}
cout<<endl;
}
for (int x=a-1;x>0;x--)
{
cout<<x;
for (int y=x;y>1;y--)
{
cout<<x;
}
cout<<endl;
}
if (i==f-1) continue;
cout<<endl;
}
}
}
and here is my I/O :
Code: Select all
2
3
2
1
22
333
22
1
1
22
333
22
1
4
3
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
thanks in advance .
Re: 488 - PRESENTATION ERROR!
Posted: Mon Mar 18, 2013 10:14 pm
by brianfry713
See:
http://ideone.com/bOWwDv
For input:
The correct output is:
Code: Select all
1
22
333
22
1
1
22
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
Your output is:
Code: Select all
1
22
333
22
1
1
22
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
As you can see, there is a blank line missing.
Re: 488 - Triangle Wave
Posted: Mon Mar 18, 2013 10:21 pm
by brianfry713
Don't double post.
488 - Triangle Wave WA?
Posted: Thu Mar 28, 2013 6:46 am
by mfjuzar
Why did I keep getting WA? The program input and output is exactly the same as the problem example,
I'm browsing the forum for my problems but it seems that I already get my code right, I've checked the blank lines needed too, but still
Code: Select all
var
c,i,k,wave,cases,amp,ampd,j: integer;
a,f:array [1..10000] of integer;
begin
readln(c);
writeln;
for k:=1 to c do begin
readln(a[k]);
readln(f[k]);
if k=c then else writeln;
end;
for cases:= 1 to c do begin
for wave:= 1 to f[cases] do begin
for amp:= 1 to a[cases] do begin
for i:= 1 to amp do begin
write (amp);
end;
writeln;
end;
for ampd:= amp-1 downto 1 do begin
for j:= ampd downto 1 do begin
write (ampd);
end;
writeln;
end;
if wave=f[cases] then else writeln;
end;
if cases=c then else writeln;
end;
end.
Re: 488 - Triangle Wave WA?
Posted: Thu Mar 28, 2013 9:28 pm
by brianfry713
Don't print a blank line at the start of the output.
Re: 488 - Triangle Wave WA?
Posted: Sun Mar 31, 2013 5:05 pm
by mfjuzar
brianfry713 wrote:Don't print a blank line at the start of the output.
It doesn't print any
Re: 488 - Triangle Wave WA?
Posted: Mon Apr 01, 2013 9:40 pm
by brianfry713
Why is line 7 of your code writeln;?
488 WA
Posted: Wed Jun 19, 2013 9:05 am
by safait
what is the in my code:
Code: Select all
#include<stdio.h>
int main()
{
int a,f,i,j,x,t;
scanf("%d",&t);
i=t-1;
while(t-->0)
{
scanf("%d%d",&a,&f);
if(t<i)
printf("\n");
for(i=0;i<f;i++){
for(j=1;j<=a;j++){
for(x=0;x<j;x++)
printf("%d",j);
printf("\n");
}
j-=2;
for(;j>=1;j--){
for(x=0;x<j;x++)
printf("%d",j);
printf("\n");
}
if(i<f-1)
printf("\n");
}
}
return 0;
}
Re: 488 WA
Posted: Wed Jun 19, 2013 11:46 pm
by brianfry713
Input:
AC output:
Code: Select all
1
22
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
You are reusing i in your code that is causing the blank line not to be printed in this case.