706 - LCD Display

All about problems in Volume 7. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 706 - LC-Display

Post by lighted »

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

xiexinxinlove
New poster
Posts: 6
Joined: Thu Jul 10, 2014 2:19 pm

Re: 706 - LC-Display

Post 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. :-)

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 706 - LCD Display

Post by Shahidul.CSE »

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

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 706 - LCD Display

Post by brianfry713 »

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!

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 706 - LCD Display

Post 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.
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

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 706 - LCD Display

Post 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
Check input and AC output for thousands of problems on uDebug!

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 706 - LCD Display

Post by Shahidul.CSE »

Thanks, bryanfry713, got AC. :D
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

Nahian.Sunny
New poster
Posts: 6
Joined: Tue Oct 21, 2014 12:51 pm

Re: 706 - LCD Display

Post 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
Last edited by Nahian.Sunny on Mon Nov 03, 2014 1:05 pm, edited 2 times in total.

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 706 - LCD Display

Post 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
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Xoros
New poster
Posts: 3
Joined: Fri Jan 16, 2015 2:31 pm

Re: 706 - LCD Display

Post 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

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 706 - LCD Display

Post by brianfry713 »

Output a blank line after each number, including the last one.
Check input and AC output for thousands of problems on uDebug!

pakosh
New poster
Posts: 3
Joined: Wed Oct 29, 2014 2:09 am

Re: 706 - LCD Display

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

Post Reply

Return to “Volume 7 (700-799)”