Page 18 of 19

488 SubmissionErr. why?

Posted: Thu Sep 26, 2013 12:30 am
by uzzal121
I cant understand. why submission error?

Code: Select all

#include <stdio.h>

int printing(int x)
{
	int i;
	for ( i = 0; i < x; i++)
		printf("%d",x);

	printf("\n");

	return 0;
}

int main()
{

	int tst_cas, f, w, i, j, triger =0 ; // w for Amplitude, f for Frequency

	scanf("%d", &tst_cas);

	while( tst_cas--)
	{
		scanf("%d %d",&f,&w);
		w= w+1;
		for ( j = 1; j < f; j++)
		{
			if(triger)	printf("\n");  /* we need not print new line after the last output. so I use it here. 
                                                              the condition controls it not to print new line for first time output  */

			for(i=1; i<=w; i++)
				printing(i);

			for(i=w-1; i>=1; i--)
				printing(i);

			triger =1;
		}
	}

	return 0;
}



Re: 488 SubmissionErr. why?

Posted: Fri Sep 27, 2013 11:13 pm
by brianfry713

Re: 488 WA

Posted: Thu Nov 21, 2013 12:50 pm
by Shihab
Help!

Code: Select all

#include<stdio.h>
int main()
{
    int Amp,I,K,L,i=1,j=1;
    long Fre,test_case;
//    FILE *fi;
//    fi=fopen("J:\\uva\\Trying\\Input.txt","r");
    scanf("%ld",&test_case);
    //fscanf(fi,"%ld",&test_case);
    while(j<=test_case)
    {
        //fscanf(fi,"%d%ld",&Amp,&Fre);
        i=1;
        scanf("%d%ld",&Amp,&Fre);
        while(i<=Fre)
        {
            for(K=1; K<=Amp; K++)
            {
                if(K!=1)
                    printf("\n");
                for(L=1; L<=K; L++)
                    printf("%d",K);
            }
            for(K=Amp-1; K>=1; K--)
            {
                printf("\n");
                for(L=1; L<=K; L++)
                    printf("%d",K);
            }
            if(i!=Fre)
                printf("\n\n");
            i++;
        }
        if(j!=test_case)
            printf("\n\n");
        j++;
    }
    //fclose(fi);
    return 0;
}


Re: 488 WA

Posted: Thu Nov 21, 2013 8:36 pm
by brianfry713
Print a newline char at the end of the last line.

Re: 488 WA

Posted: Sun Nov 24, 2013 9:59 am
by Shihab
Can u be specific

Re: 488 WA

Posted: Tue Nov 26, 2013 12:34 am
by brianfry713
I can't be any more specific than that. The last line of the output should have the new line character '\n' at the end of it.

Re: 488 WA

Posted: Tue Nov 26, 2013 9:12 am
by Shihab
Thanks, I got AC

488 WA

Posted: Tue Dec 03, 2013 1:54 pm
by sajal2k8
A C

Re: 488 WA

Posted: Tue Dec 03, 2013 11:45 pm
by brianfry713
Don't print a blank line at the start of the output.

Re: 488 - Triangle Wave

Posted: Tue Aug 26, 2014 3:52 pm
by refatsardar

Code: Select all

Code is deleted.WA code is also working, may be there was problem with copy/paste :D Thanks Lighted

Re: 488 - Triangle Wave

Posted: Tue Aug 26, 2014 5:52 pm
by lighted
Your "WA" code is accepted code. Problems with copy/paste? :D

Don't post full accepted code just post necessary part. :)

Re: 488 - Triangle Wave

Posted: Sat Nov 22, 2014 11:39 pm
by Xenon Kfr
WA .why ?

Code: Select all

#include<stdio.h>
int main()
{
    long long t,a,f,i,j,k,temp,ii;
    while((scanf("%lld",&t))!=EOF)
    {
        printf("\n");
        for(ii=0;ii<t;ii++)
        {
            scanf("%lld",&temp);
            scanf("%lld",&f);
            for(i=0;i<f;i++)
            {
                a=temp;
                for(j=1;j<=a;j++)
                {
                    for(k=1;k<=j;k++)
                        printf("%d",j);
                    printf("\n");
                }
                if(a/2==1)
                    a=a-1;
                for(j=a;j>0;j--)
                {
                    for(k=j;k>0;k--)
                        printf("%d",j);
                    printf("\n");
                }
                printf("\n");
            }
        }
    }


    return 0;
}

Re: 488 - Triangle Wave

Posted: Sun Nov 23, 2014 4:41 pm
by lighted
The input begins with a single positive integer on a line by itself indicating the number of the cases following
According to problem description you should read a number of test cases once, loop is unnecessary. Your loop prints extra blank line at the beginning. Don't print extra blank line after last wave form.

Input

Code: Select all

2

6
5

1
19
Acc Output

Code: Select all

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1
Don't forget to remove your codes after getting accepted. 8)

Re: 488 - Triangle Wave

Posted: Sun Jan 25, 2015 5:57 pm
by Sabrina Haque
got an AC

Code: Select all


#include<stdio.h>

int main()
{
    int test_case,frequency,amplitude,i,j,k,m;

    scanf("%d",&test_case);
     printf("\n");
    for(i=0;i<test_case;i++)
    {
        scanf("%d",&amplitude);
        scanf("%d",&frequency);
         printf("\n");

         for(m=0;m<frequency;m++)
        {
           for(j=1;j<=amplitude;j++)
        {
            for(k=0;k<j;k++)

                 printf("%d",j);
                printf("\n");
        }
        for(j=amplitude-1;j>0;j--)
        {
            for(k=j;k>=1;k--)

                 printf("%d",j);
                printf("\n");
        }
        printf("\n");

        }

    }

    return 0;

}

Re: 488 - Triangle Wave

Posted: Wed Aug 05, 2015 1:56 pm
by ahashans
I can't find the problem of my code. Its showing wrong answer.
Here is the code:

Code: Select all

#include<iostream>
using namespace std;
int main()
{
	int i,j,k,amplitude,frequency,test_case;
	cin>> test_case;
	cin>>amplitude>>frequency;
	while(test_case--){
	for(k=1;k<=frequency;k++){
	for(i=1;i<=amplitude;i++){
		for(j=1;j<=i;j++){
			cout<<i;
		}
		cout<<endl;
	}
	for(i=amplitude-1;i>=1;i--){
		for(j=1;j<=i;j++){
			cout<<i;
		}
		cout<<endl;
	}
	if(k<frequency)cout<<endl;
	}
	}
	return 0;
}