Page 15 of 15

Re: 706 - LC-Display

Posted: Sat Jul 12, 2014 5:27 pm
by lighted
I think it will be good if you remove your code after getting accepted.

Re: 706 - LC-Display

Posted: Mon Jul 14, 2014 3:13 pm
by xiexinxinlove
lighted wrote:I think it will be good if you remove your code after getting accepted.
I am sorry.I have removed it. :-)

Re: 706 - LCD Display

Posted: Mon Sep 29, 2014 6:48 pm
by Shahidul.CSE

Code: Select all

Code Removed

Re: 706 - LCD Display

Posted: Mon Sep 29, 2014 7:49 pm
by brianfry713
For code 1 on the sample input you're printing extra blank lines at the end.

Re: 706 - LCD Display

Posted: Mon Sep 29, 2014 8:34 pm
by Shahidul.CSE
brianfry713 wrote:For code 1 on the sample input you're printing extra blank lines at the end.
Ok, I also noticed it when I check output for sample input. But couldn't fix it :(

But whats wrong with 2nd code? It looks fine for different cases, but why getting WA? Please help me for 2nd code.

Re: 706 - LCD Display

Posted: Tue Sep 30, 2014 9:30 pm
by brianfry713
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

Re: 706 - LCD Display

Posted: Wed Oct 01, 2014 1:25 pm
by Shahidul.CSE
Thanks, bryanfry713, got AC. :D

Re: 706 - LCD Display

Posted: Tue Oct 28, 2014 8:39 am
by Nahian.Sunny
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 ...

Code: Select all

REMOVE AFTER AC :D

Re: 706 - LCD Display

Posted: Tue Oct 28, 2014 11:22 am
by lighted
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++)
    ..
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

Re: 706 - LCD Display

Posted: Sun Jan 18, 2015 3:45 pm
by Xoros
I keep getting presentation errors, can someone identify my error? I can't seem to figure it out.

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;
}
Thanks in advance! :3

Re: 706 - LCD Display

Posted: Mon Jan 19, 2015 10:00 pm
by brianfry713
Output a blank line after each number, including the last one.

Re: 706 - LCD Display

Posted: Sat Sep 26, 2015 1:50 am
by pakosh
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

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);
        ...
}