488 - Triangle Wave
Moderator: Board moderators
Why output Limit E...??????
*************code removed***************
*************code removed***************
Last edited by ranacse05 on Tue Apr 24, 2007 7:46 pm, edited 1 time in total.
I like to solve problems.
Check your code carefully.
Hope it helps.
Code: Select all
for(i=0;i<num;i++)
...
for(k=0;k<b;k++)
...
for(i=0;i<a;i++) // i again ???
...
Ami ekhono shopno dekhi...
HomePage
HomePage
Why PE ?
plz help me
#include "stdio.h"
int main()
{
int a,b,i,j,k,num;
while(scanf("%d",&num)==1)
{
for(i=0;i<num;i++)
{
scanf("%d %d",&a,&b);
printf("\n");
for(k=0;k<b;k++)
{
for(i=0;i<a;i++)
{ for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
for(i=a-2;i>=0;i--)
{ for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
printf("\n");
}
printf("\n");
}
}
return 0;
}
plz help me
#include "stdio.h"
int main()
{
int a,b,i,j,k,num;
while(scanf("%d",&num)==1)
{
for(i=0;i<num;i++)
{
scanf("%d %d",&a,&b);
printf("\n");
for(k=0;k<b;k++)
{
for(i=0;i<a;i++)
{ for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
for(i=a-2;i>=0;i--)
{ for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
printf("\n");
}
printf("\n");
}
}
return 0;
}
I like to solve problems.
Rocky try this :
#include "stdio.h"
int main()
{
int a,b,i,j,k,l,num,count,total;
total=0;
while(scanf("%d",&num)==1)
{
count=0;
for(l=0;l<num;l++)
{
scanf("%d %d",&a,&b);
printf("\n");
total+=b;
for(k=0;k<b;k++)
{
for(i=0;i<a;i++)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
count++;
for(i=a-2;i>=0;i--)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
if(count!=total)
printf("\n");
}
}
}
return 0;
}
But why PE????????????
#include "stdio.h"
int main()
{
int a,b,i,j,k,l,num,count,total;
total=0;
while(scanf("%d",&num)==1)
{
count=0;
for(l=0;l<num;l++)
{
scanf("%d %d",&a,&b);
printf("\n");
total+=b;
for(k=0;k<b;k++)
{
for(i=0;i<a;i++)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
count++;
for(i=a-2;i>=0;i--)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
if(count!=total)
printf("\n");
}
}
}
return 0;
}
But why PE????????????
I like to solve problems.
-
- Learning poster
- Posts: 81
- Joined: Wed May 09, 2007 9:59 pm
- Location: (CSE,DU) Dhaka,Bangladesh
Here is my code & i got PE. Ples help me if any mistakes
#include <stdio.h>
void main(void)
{
unsigned long i,j,k,amp,freq,count,m,n,l;
count=0;
//freopen("input3.in","r",stdin);
scanf("%lu",&n);
for(l=1;l<=n;l++)
{
scanf("%lu %lu",&,&freq);
// if(count!=0)
//printf("\n");
if(amp==0)
{
for(i=0;i<freq;i++)
if(i!=freq-1)
// printf("\n");
// count++;
continue;
}
for(i=0;i<freq;i++)
{
//if(count!=0)
// printf("\n");
for(j=1;j<=amp;j++)
{
for(k=0;k<j;k++)
printf("%lu",j);
printf("\n");
}
for(j=amp-1;j>=1;j--)
{
for(k=0;k<j;k++)
printf("%lu",j);
if(j!=1)
printf("\n");
}
if(i==freq-1&&l==n)
continue;
else if(i!=freq-1||l!=n)
printf("\n\n");
}
//count++;
if(l!=n)
//break;
//else
printf("\n");
}
}
void main(void)
{
unsigned long i,j,k,amp,freq,count,m,n,l;
count=0;
//freopen("input3.in","r",stdin);
scanf("%lu",&n);
for(l=1;l<=n;l++)
{
scanf("%lu %lu",&,&freq);
// if(count!=0)
//printf("\n");
if(amp==0)
{
for(i=0;i<freq;i++)
if(i!=freq-1)
// printf("\n");
// count++;
continue;
}
for(i=0;i<freq;i++)
{
//if(count!=0)
// printf("\n");
for(j=1;j<=amp;j++)
{
for(k=0;k<j;k++)
printf("%lu",j);
printf("\n");
}
for(j=amp-1;j>=1;j--)
{
for(k=0;k<j;k++)
printf("%lu",j);
if(j!=1)
printf("\n");
}
if(i==freq-1&&l==n)
continue;
else if(i!=freq-1||l!=n)
printf("\n\n");
}
//count++;
if(l!=n)
//break;
//else
printf("\n");
}
}
Search the board first. Don't open a new thread if one already exists. If there is no thread then you can open a new one. But then you should specify the problem name.
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- Learning poster
- Posts: 81
- Joined: Wed May 09, 2007 9:59 pm
- Location: (CSE,DU) Dhaka,Bangladesh
488, PE,PLES help
2
4
3
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
3
2
1
22
333
22
1
1
22
333
22
1
Here is my code i got PE PLES Help.
Note: There is no '\n' in my output in last case. So what is the problem??
4
3
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
1
22
333
4444
333
22
1
3
2
1
22
333
22
1
1
22
333
22
1
Here is my code i got PE PLES Help.
Note: There is no '\n' in my output in last case. So what is the problem??
Search the board first. Don't open a new thread if there is one already.
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 1
- Joined: Sun Jul 15, 2007 10:32 pm
I put this code e i had PE too, someone could see what's wrong?
Code: Select all
#include<stdio.h>
int main(){
int n, amp, hz, i, j, l, k;
scanf("%d", &n);
for(k = 1; k <= n; k++){
if(k > 1)
printf("\n");
scanf("%d", &);
scanf("%d", &hz);
for(l = 1; l <= hz; l++){
for(i = 1; i <= amp; i++){
for(j = 1; j <= i; j++)
printf("%d", i);
printf("\n");
}
for(i = amp-1; i >= 1; i--){
for(j = 1; j <= i; j++)
printf("%d", i);
if(l == hz && i == 1 && k == n)
continue;
else
printf("\n");
}
if(l != hz)
printf("\n");
}
}
}
I've tried everything and still PE help plese
Code: Select all
#include<stdio.h>
main()
{
int i,j,k,p,f=1;
int amp=0,freq=0,test=0;
scanf("%d",&test);
for(p=1;p<=test;p++)
{
scanf("%d",&);
scanf("%d",&freq);
for(i=1;i<=freq;i++)
{
for(j=1;j<=amp;j++)
{
for(k=1;k<=j;k++)
{
printf("%d",j);
}
printf("\n");
}
for(j=amp-1;j>=1;j--)
{
for(k=1;k<=j;k++)
{
printf("%d",j);
}
printf("\n");
}
if(i!=freq)
printf("\n");
}
}
return 0;
}
-
- New poster
- Posts: 1
- Joined: Sat Nov 03, 2007 4:20 am
488 TLE
Code: Select all
#include<iostream>
using namespace std;
int main()
{
int x,i,j,a=0,b=0,c=1;
cin>>x;
while(x--)
{
i=0;j=0;
cin>>i>>j;
while(j--)
{
a=0;b=0;c=1;
for(a=1;a<=i;a++)
{
for(b=0;b<a;b++)
{
cout<<c;
}
c++;
cout<<endl;
}
c=i-1;
for(a=i;a>0;a--)
{
for(b=1;b<a;b++)
{
cout<<c;
}
c--;
if(c==0&j==0)continue;
cout<<endl;
}
}
}
//system("pause");
return 0;
}