Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一直说是Wrong Answer,希望有同学指点一下问题是出在哪儿

Posted by ACM06001blue at 2011-05-16 16:24:40 on Problem 1102
#define ZERO	0x3f
#define ONE		0x06
#define TWO		0x5b
#define THREE	0x4f
#define FOUR	0x66
#define FIVE	0x6d
#define SIX		0x7d
#define SEVEN	0x07
#define EIGHT	0x7f
#define NINE	0x6f

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

char matrix[25][100];

void AddHorizantal(int len, int x, int y)
{
	for (int i=0; i<len; i++)
		matrix[x][++y] = '-';
}

void AddVertical(int len, int x, int y)
{
	for (int i=0; i<len; i++)
		matrix[++x][y] = '|';
}

void UpdateMatrix(int num, int len, int pos)
{
	int locx = 0;
	int locy = pos*(len+3);

	if (num & 0x01)
		AddHorizantal(len,locx,locy);
	if (num & 0x02)
		AddVertical(len,locx,locy+len+1);
	if (num & 0x04)
		AddVertical(len,locx+len+1,locy+len+1);
	if (num & 0x08)
		AddHorizantal(len,locx+len+1+len+1,locy);
	if (num & 0x10)
		AddVertical(len,locx+len+1,locy);
	if (num & 0x20)
		AddVertical(len,locx,locy);
	if (num & 0x40)
		AddHorizantal(len,locx+len+1,locy);
}

int main()
{
	int s;
	string n;
	while (cin>>s>>n)
	{
		if (0 == s && 0 == n.compare("0")) break;

		memset(matrix, ' ', sizeof(matrix));

		for (int i=0; i<n.size(); i++)
		{
			if (n[i] == '0')
				UpdateMatrix(ZERO, s, i);
			else if (n[i] == '1')
				UpdateMatrix(ONE, s, i);
			else if (n[i] == '2')
				UpdateMatrix(TWO, s, i);
			else if (n[i] == '3')
				UpdateMatrix(THREE, s, i);
			else if (n[i] == '4')
				UpdateMatrix(FOUR, s, i);
			else if (n[i] == '5')
				UpdateMatrix(FIVE, s, i);
			else if (n[i] == '6')
				UpdateMatrix(SIX, s, i);
			else if (n[i] == '7')
				UpdateMatrix(SEVEN, s, i);
			else if (n[i] == '8')
				UpdateMatrix(EIGHT, s, i);
			else if (n[i] == '9')
				UpdateMatrix(NINE, s, i);
		}
		

		int height = 2*s+3;
		int width = (s+3)*n.size();

		for (int x=0; x<height; x++)
		{
			for (int y=0; y<width; y++)
			{
				cout << matrix[x][y];
			}
			cout << endl;
		}

		cout << endl;

	}

	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator