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
uzzal121
New poster
Posts: 1 Joined: Thu Sep 26, 2013 12:08 am
Post
by uzzal121 » Thu Sep 26, 2013 12:30 am
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;
}
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Fri Sep 27, 2013 11:13 pm
Check input and AC output for thousands of problems on
uDebug !
Shihab
New poster
Posts: 33 Joined: Thu Jun 13, 2013 1:19 pm
Post
by Shihab » Thu Nov 21, 2013 12:50 pm
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;
}
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Thu Nov 21, 2013 8:36 pm
Print a newline char at the end of the last line.
Check input and AC output for thousands of problems on
uDebug !
Shihab
New poster
Posts: 33 Joined: Thu Jun 13, 2013 1:19 pm
Post
by Shihab » Sun Nov 24, 2013 9:59 am
Can u be specific
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Tue Nov 26, 2013 12:34 am
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.
Check input and AC output for thousands of problems on
uDebug !
Shihab
New poster
Posts: 33 Joined: Thu Jun 13, 2013 1:19 pm
Post
by Shihab » Tue Nov 26, 2013 9:12 am
Thanks, I got AC
sajal2k8
New poster
Posts: 16 Joined: Mon Nov 18, 2013 5:15 pm
Post
by sajal2k8 » Tue Dec 03, 2013 1:54 pm
A C
Last edited by
sajal2k8 on Sun Dec 08, 2013 8:18 pm, edited 1 time in total.
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Tue Dec 03, 2013 11:45 pm
Don't print a blank line at the start of the output.
Check input and AC output for thousands of problems on
uDebug !
refatsardar
New poster
Posts: 6 Joined: Sat Jun 07, 2014 10:22 pm
Post
by refatsardar » Tue Aug 26, 2014 3:52 pm
Code: Select all
Code is deleted.WA code is also working, may be there was problem with copy/paste :D Thanks Lighted
Last edited by
refatsardar on Tue Aug 26, 2014 8:26 pm, edited 2 times in total.
lighted
Guru
Posts: 587 Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek
Post
by lighted » Tue Aug 26, 2014 5:52 pm
Your
"WA" code is accepted code. Problems with copy/paste?
Don't post full accepted code just post necessary part.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Xenon Kfr
New poster
Posts: 13 Joined: Tue Nov 18, 2014 1:14 am
Post
by Xenon Kfr » Sat Nov 22, 2014 11:39 pm
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;
}
lighted
Guru
Posts: 587 Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek
Post
by lighted » Sun Nov 23, 2014 4:41 pm
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
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.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Sabrina Haque
New poster
Posts: 3 Joined: Fri Jan 23, 2015 9:33 am
Post
by Sabrina Haque » Sun Jan 25, 2015 5:57 pm
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",&litude);
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;
}
Last edited by
brianfry713 on Tue Jan 27, 2015 12:56 am, edited 1 time in total.
Reason: Added code blocks
ahashans
New poster
Posts: 1 Joined: Wed Aug 05, 2015 1:46 pm
Post
by ahashans » Wed Aug 05, 2015 1:56 pm
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;
}