Page 2 of 15

706 i can't figure it out

Posted: Sat Apr 26, 2003 7:33 pm
by zero
\ :evil:
i tried all data on my pc and it is right
but i still got a WA
please help me

i've considered
0 case
blanks

what else did i miss??

Posted: Mon Apr 28, 2003 9:01 pm
by Farid Ahmadov
Give me some of your inputs and output exactly as your program generates and I'll try to help you to fix your mistake.

Posted: Tue Apr 29, 2003 9:10 am
by zero
thanks so much
but i alreaky found the problem

however, i don't understand why the question would appear.
because i declared a global variable : char a[10][4][3]
and initialize each element in a sub function
everything is right in the sub func
but at once leave the sub func-- a[5][0][0] would disappear
therefore i should initialize it again in the main function

it's a weird question but i use a stupid method to solve it!
:-?
thank you anyway

Posted: Tue Apr 29, 2003 10:41 am
by Dominik Michniewski
I guess that you still have mistake in your code.
If something in global variables is initialized, it doesn't "disappear" self :))

Maybe you initialize too much elements in some loop ?

DM

Posted: Tue Apr 29, 2003 10:54 am
by zero
well, it is how i initialize number
strcpy(number[5][0]," - ");
where number is char number[10][5][4]

but it dose lose number[5][0][0] which should be' '
i don't know@@

Posted: Wed Apr 30, 2003 7:33 am
by Dominik Michniewski
Post me definiotion of your table and function , which initialize it :) I try to find your mistake :))

DM

Posted: Wed Apr 30, 2003 6:04 pm
by zero
Dominik Michniewski wrote:Post me definiotion of your table and function , which initialize it :) I try to find your mistake :))

DM
void digitform(void)
{
strcpy(number[0][0]," - "); strcpy(number[5][0]," - ");
strcpy(number[0][1],"| | "); strcpy(number[5][1],"| ");
strcpy(number[0][2]," "); strcpy(number[5][2]," - ");
strcpy(number[0][3],"| | "); strcpy(number[5][3]," | ");
strcpy(number[0][4]," - "); strcpy(number[5][4]," - ");



return;
}

PS: funtion digitform() does like the way above from 0 to 9

int main()
{
int s;

digitform();
return 0;
}

706

Posted: Fri May 30, 2003 6:55 pm
by reiners
I received WA for the program included below. Can anyone please tell me an input on which it fails, and what the expected output should be for that input?

Code: Select all

/*   @JUDGE_ID:   29339ZA   706   C++   "Getting Started"   */

#include<iostream.h>
#include <string>
#include <cmath>
using namespace std;

void display(int s, int n);
void displayHoriz(int row, int s, int digits[], int digitsLen);
void displayVert(int row, int s, int digits[], int digitsLen);

void main()
{
      int s, n;

      while (cin >> s >> n) {
		  if (s == 0 && n == 0) {
			  break;
		  }
		  display(s, n);
      }
}


const char DIGITS[10][5][3] = {{{' ', '-', ' '},  // 0
                                           {'|', ' ', '|'},
                                           {' ', ' ', ' '},
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', ' ', ' '},  // 1
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '},
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '}},
                                          {{' ', '-', ' '},  // 2
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '},
                                           {'|', ' ', ' '},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 3
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', ' ', ' '},  // 4
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '}},
                                          {{' ', '-', ' '},  // 5
                                           {'|', ' ', ' '},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 6
                                           {'|', ' ', ' '},
                                           {' ', '-', ' '},
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 7
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '},
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '}},
                                          {{' ', '-', ' '},  // 8
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '},
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 9
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '}}};

void display(int s, int n) {
	int digitsLen = int(log10(n)) + 1;
    int* digits = new int[digitsLen];
    int nn = n;
	int i;
    for (i = digitsLen - 1; i >= 0; i--) {
        digits[i] = nn % 10;
        nn /= 10;
    }
    
    for (i = 0; i < 5; i++) {
        if (i % 2 == 0) {
            displayHoriz(i, s, digits, digitsLen);
        }
        else {
            displayVert(i, s, digits, digitsLen);
        }
    }
    
    cout << endl;
}

void displayHoriz(int row, int s, int digits[], int digitsLen) {
    for (int i = 0; i < digitsLen; i++) {
        int digit = digits[i];
        cout << ' ';
        for (int j = 0; j < s; j++) {
            cout << DIGITS[digit][row][1];
        }
        cout << ' ';
        if (i < digitsLen - 1) {
            cout << ' ';
        }
    }
    cout << endl;
}

void displayVert(int row, int s, int digits[], int digitsLen) {
    for (int k = 0; k < s; k++) {
        for (int i = 0; i < digitsLen; i++) {
            int digit = digits[i];
            cout << DIGITS[digit][row][0];
            for (int j = 0; j < s; j++) {
                cout << ' ';
            }
            cout << DIGITS[digit][row][2];
            if (i < digitsLen - 1) {
                cout << ' ';
            }
        }
        cout << endl;
    }
}

706 WA

Posted: Sun Jun 01, 2003 1:04 am
by reiners
Never mind. It's working now.

706 WA

Posted: Mon Jul 21, 2003 4:49 am
by kate
Not sure what's causing it.

Code: Select all

#include <iostream>
#include <vector>
#include <string>
using namespace std;

const int show[10][7] =
{
/*0*/	{1,1,1,1,1,1,0,},
/*1*/	{0,1,1,0,0,0,0,},
/*2*/	{1,1,0,1,1,0,1,},
/*3*/	{1,1,1,1,0,0,1,},
/*4*/	{0,1,1,0,0,1,1,},
/*5*/	{1,0,1,1,0,1,1,},
/*6*/	{1,0,1,1,1,1,1,},
/*7*/	{1,1,1,0,0,0,0,},
/*8*/	{1,1,1,1,1,1,1,},
/*9*/	{1,1,1,1,0,1,1,},
};

int main()
{
	int size;	char ch;	vector<int> num; string yes,no;
	cin >> size; 
	cin.get(ch);
	for(int i=0;i<size;i++) {
		yes+='-'; no+=' ';
	}
	cin.get(ch);
	while(ch!='\n') {
		num.push_back(int(ch)-48);
		cin.get(ch);
	}
	while(size!=0 || num.size()>1 || num[0]!=0) {
		if(size!=0) {
			// top
			for(int j=0;j<num.size();j++) {
				cout << " ";
				if(show[num[j]][0])	cout << yes;
				else cout << no;
				cout << " ";
				if(j<num.size()-1) cout << " ";				
			}
			cout << endl;
			// below top
			for(int m=0;m<size;m++) {
				for(int n=0;n<num.size();n++) {
					if(show[num[n]][5]) cout << "|";
					else cout << " ";
					cout << no;
					if(show[num[n]][1]) cout << "|";
					else cout << " ";
					if(n<num.size()-1) cout << " ";
				}
				cout << endl;
			}
			// middle
			for(int k=0;k<num.size();k++) {
				cout << " ";
				if(show[num[k]][6])	cout << yes;
				else cout << no;
				cout << " ";
				if(k<num.size()-1) cout << " ";				
			}
			cout << endl;
			// below middle
			for(int o=0;o<size;o++) {
				for(int p=0;p<num.size();p++) {
					if(show[num[p]][4]) cout << "|";
					else cout << " ";
					cout << no;
					if(show[num[p]][2]) cout << "|";
					else cout << " ";
					if(p<num.size()-1) cout << " ";
				}
				cout << endl;
			}
			// bottom
			for(int l=0;l<num.size();l++) {
				cout << " ";
				if(show[num[l]][3])	cout << yes;
				else cout << no;
				cout << " ";
				if(l<num.size()-1) cout << " ";				
			}
			cout << endl;
			num.clear(); yes=""; no="";
			cout << endl;
			cin >> size; 
			cin.get(ch);
			for(int q=0;q<size;q++) {
				yes+='-'; no+=' ';
			}
			cin.get(ch);
			while(ch!='\n') {
				num.push_back(int(ch)-48);
				cin.get(ch);
			}
		}
	}
	return 0;
}
[/code]

Posted: Mon Jul 21, 2003 8:47 am
by carneiro
should we concern negative numbers ?

Posted: Tue Jul 29, 2003 4:36 pm
by Joseph Kurniawan
Nope, there won't be any negative numbers in this problem

Please help me too

Posted: Fri Aug 01, 2003 5:10 pm
by ileti
In my program all numbers correct but WA is giving.I can missunderstood to line status.
e.g 4 2
// i wrote the solution here
then pass next line or wait for new input ?
In other word last input was displayed is there any new line ?

May be there is different problem.If there any advice, tell me
thanks...

Please help me too

Posted: Fri Aug 01, 2003 5:11 pm
by ileti
In my program all numbers correct but WA is giving.I can missunderstood to line status.
e.g 4 2
// i wrote the solution here
then pass next line or wait for new input ?
In other word last input was displayed is there any new line ?

May be there is different problem.If there any advice, tell me
thanks...

706 WA

Posted: Thu Sep 18, 2003 8:17 pm
by dhc
#include <stdio.h>
#include <string.h>

void oito(int i,int m,int numero)
{
int j;

if (i==0)
{
printf(" ");
for (j=0;j<m;j++)
{
if (numero != 1 && numero != 4) printf("-");
else printf(" ");
}
printf(" ");
printf(" ");
}

if (i==1)
{
if (numero != 1 && numero != 2 && numero != 3 && numero != 7)
{
printf("|");
}
else
{
printf(" ");
}
for (j=0;j<m;j++)
{
printf(" ");
}
if (numero != 5 && numero != 6)
{
printf("|");
}
else
{
printf(" ");
}
printf(" ");
}

if (i==2)
{
printf(" ");
for (j=0;j<m;j++)
{
if (numero != 1 && numero != 0 && numero != 7) printf("-");
else printf(" ");
}
printf(" ");
printf(" ");
}

if (i==3)
{
if (numero == 2 || numero == 6 || numero == 8 || numero == 0)
{
printf("|");
}
else
{
printf(" ");
}
for (j=0;j<m;j++)
{
printf(" ");
}
if (numero != 2)
{
printf("|");
}
else
{
printf(" ");
}
printf(" ");
}

if (i==4)
{
printf(" ");
for (j=0;j<m;j++)
{
if (numero != 1 && numero != 4 && numero != 7) printf("-");
else printf(" ");
}
printf(" ");
printf(" ");
}
}



void main ()
{
int m,i,j,h;
char s[100];
char *f = "0";
while (scanf("%d %s",&m,&s))
{
if (m == 0 && (strcmp(f,s) == 0)) return;
h = strlen(s);

for (i=0;i<h;i++)
{
if (s>=48 && s<=57)
{
if (i==0) printf(" ");
oito(0,m,s-48);
}
}
printf("\n");

for(j=0;j<m;j++)
{
for (i=0;i<h;i++)
{
if (s>=48 && s<=57)
{
if (i==0) printf(" ");
oito(1,m,s-48);
}
}
printf("\n");
}


for (i=0;i<h;i++)
{
if (s>=48 && s<=57)
{
if (i==0) printf(" ");
oito(2,m,s-48);
}
}
printf("\n");

for (j=0;j<m;j++)
{
for (i=0;i<h;i++)
{
if (s>=48 && s[i]<=57)
{
if (i==0) printf(" ");
oito(3,m,s[i]-48);
}
}
printf("\n");
}

for (i=0;i<h;i++)
{
if (s[i]>=48 && s[i]<=57)
{
if (i==0) printf(" ");
oito(4,m,s[i]-48);
}
}
printf("\n");
}
return;
}
[c][/c]