706 - LCD Display
Moderator: Board moderators
Re: 706 - LC-Display
I think it will be good if you remove your code 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
-
- New poster
- Posts: 6
- Joined: Thu Jul 10, 2014 2:19 pm
Re: 706 - LC-Display
I am sorry.I have removed it.lighted wrote:I think it will be good if you remove your code after getting accepted.

-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 706 - LCD Display
Code: Select all
Code Removed
Last edited by Shahidul.CSE on Wed Oct 01, 2014 1:32 pm, edited 1 time in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 706 - LCD Display
For code 1 on the sample input you're printing extra blank lines at the end.
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 706 - LCD Display
Ok, I also noticed it when I check output for sample input. But couldn't fix itbrianfry713 wrote:For code 1 on the sample input you're printing extra blank lines at the end.

But whats wrong with 2nd code? It looks fine for different cases, but why getting WA? Please help me for 2nd code.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 706 - LCD Display
For the 1st code change line 10 to:
if(s==0 && num[0]=='0' && num[1]=='\0')
For the 2nd code try input: 1 0
if(s==0 && num[0]=='0' && num[1]=='\0')
For the 2nd code try input: 1 0
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 706 - LCD Display
Thanks, bryanfry713, got AC. 

Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- New poster
- Posts: 6
- Joined: Tue Oct 21, 2014 12:51 pm
Re: 706 - LCD Display
I have tried everything, but still getting "wrong answer"
My program seens alright... Did a lot of testing and couldn't find any error;
- I'm considering leading zeros (printing them)
- I'm printing the blank columns between digits
- I'm also printing new lines after the numbers
- I've read in a topic that printing two new lines in the last output could solve the problem... No luck...
Plz can anyone help? here is my code ...
My program seens alright... Did a lot of testing and couldn't find any error;
- I'm considering leading zeros (printing them)
- I'm printing the blank columns between digits
- I'm also printing new lines after the numbers
- I've read in a topic that printing two new lines in the last output could solve the problem... No luck...
Plz can anyone help? here is my code ...
Code: Select all
REMOVE AFTER AC :D
Last edited by Nahian.Sunny on Mon Nov 03, 2014 1:05 pm, edited 2 times in total.
Re: 706 - LCD Display
Use code tags.
Change input reading to avoid WA.
It will give PE. Check spaces and newlines to avoid PE. I don't want look at your code if you don't use code tags
Change input reading to avoid WA.
Code: Select all
string n;
int s,i,j,l, N;
while(1)
{
cin >> s >> N;
if (N==0 && s==0)
break;
n = to_string(N);
for (l = 0; l < (2 * s + 3 ); l++)
..
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 706 - LCD Display
I keep getting presentation errors, can someone identify my error? I can't seem to figure it out.
Here is my code:
Thanks in advance! :3
Here is my code:
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
int x;
char y[11];
int z = 0;
int ntemp;
int ncnt;
int cnt2;
scanf("%d%s", &x, y);
while(x != 0)
{
for(cnt2 = 0; cnt2 < 2 * x + 3; cnt2++)
{
for(ntemp = 0; ntemp < strlen(y); ntemp++)
{
switch(y[z] - 48)
{
case 1: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < x + 2; ncnt++)
printf(" ");
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if(ncnt == x + 1)
printf("|");
else
printf(" ");
}
}
break;
case 2: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < 2 + x; ncnt++)
{
if(ncnt == 0 || ncnt == 1 + x)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if((ncnt == x + 1 && (cnt2 >= 1 && cnt2 <= x)) || (ncnt == 0 && (cnt2 >= x + 2 && cnt2 <= 2 * x + 1) ) )
printf("|");
else
printf(" ");
}
}
break;
case 3: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if(ncnt == 0 || ncnt == 1 + x)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if(ncnt == x + 1)
printf("|");
else
printf(" ");
}
}
break;
case 4: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if(((ncnt == 0 || ncnt == 1 + x) && cnt2 == x + 1) || cnt2 == 0 || cnt2 ==2*x + 2)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if(ncnt == x + 1 || (ncnt == 0 && (cnt2 >= 1 && cnt2 <= x)))
printf("|");
else
printf(" ");
}
}
break;
case 5: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < 2 + x; ncnt++)
{
if(ncnt == 0 || ncnt == 1 + x)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if((ncnt == 0 && (cnt2 >= 1 && cnt2 <= x)) || (ncnt == x + 1 && (cnt2 >= x + 2 && cnt2 <= 2 * x + 1) ) )
printf("|");
else
printf(" ");
}
}
break;
case 6: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < 2 + x; ncnt++)
{
if(ncnt == 0 || ncnt == 1 + x)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if((ncnt == 0 && (cnt2 >= 1 || cnt2 <= x)) || (ncnt == x + 1 && (cnt2 >= x + 2 && cnt2 <= 2 * x + 1) ) )
printf("|");
else
printf(" ");
}
}
break;
case 7: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < x + 2; ncnt++)
if(ncnt == 0 || cnt2 != 0 || ncnt == x + 1)
printf(" ");
else
printf("-");
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if(ncnt == x + 1)
printf("|");
else
printf(" ");
}
}
break;
case 8: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < 2 + x; ncnt++)
{
if(ncnt == 0 || ncnt == 1 + x)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if((ncnt == 0 && (cnt2 >= 1 || cnt2 <= x)) || (ncnt == x + 1 && (cnt2 >= x + 2 || cnt2 <= 2 * x + 1) ) )
printf("|");
else
printf(" ");
}
}
break;
case 9: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < 2 + x; ncnt++)
{
if(ncnt == 0 || ncnt == 1 + x)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if((ncnt == 0 && (cnt2 >= 1 && cnt2 <= x)) || (ncnt == x + 1 && (cnt2 >= x + 2 || cnt2 <= 2 * x + 1) ) )
printf("|");
else
printf(" ");
}
}
break;
case 0: if(cnt2 == 0 || cnt2 == x + 1 || cnt2 == 2 * x + 2)
{ for(ncnt = 0; ncnt < 2 + x; ncnt++)
{
if(ncnt == 0 || ncnt == 1 + x || cnt2 == x + 1)
printf(" ");
else
printf("-");
}
}
else
{
for(ncnt = 0; ncnt < x + 2; ncnt++)
{
if((ncnt == 0 && (cnt2 >= 1 || cnt2 <= x)) || (ncnt == x + 1 && (cnt2 >= x + 2 || cnt2 <= 2 * x + 1) ) )
printf("|");
else
printf(" ");
}
}
break;
}
z++;
if(ntemp + 1 != strlen(y))
printf(" ");
}
z = 0;
printf("\n");
}
scanf("%d%s", &x, y);
if(x != 0)
printf("\n");
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 706 - LCD Display
Output a blank line after each number, including the last one.
Check input and AC output for thousands of problems on uDebug!
Re: 706 - LCD Display
GOT WA for some reason. Any hint? Tried all inputs and every output is same (compared with https://www.diffchecker.com/diff).
Problem solved. There is an example how I had to change my reading
Problem solved. There is an example how I had to change my reading
Code: Select all
while (cin >> s && getline(cin, number) && !(s == 0))
{
int start = 0;
while (start < number.length() && (number[start] > '9' || number[start] < '0'))
start++;
int end = start + 1;
while (end < number.length() && number[end] >= '0' && number[end] <= '9')
end++;
number = number.substr(start, end - start);
...
}