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

数字编码方式

Posted by gemenhao at 2006-05-17 22:21:28 on Problem 1102
char DIGIT[10][8] =  {"1110111", "0010010","1011101","1011011","0111010",					  "1101011", "1101111","1010010","1111111","1111011"};
分别代表 0,1,3,4,5,6,7,8,9的方式
排列方式如下
 000
1   2
1   2
 333
4   5
4   5
 666

这样不用太多次判断

或者用
char DIGIT[10][8] =  {"-|| ||-", "  |  | ","- |-| -","- |- |-"," ||- | ", "-| - |-", "-| -||-","- |  | ","-||-||-","-||- |-"};
编码,这样不用判断每一位是'-','|'和空格
	
		int leng = strlen(s);
		for (int i = 0; i < 7; i++)
		{
				if (i % 3 == 0)
				{
					for (int n = 0; n < leng; n++)
					{
						printf(" ");
						for (int k = 0; k < w; k++)
							printf("%c",DIGIT[s[n] - '0'][i]);
						if (n != leng - 1)
							printf("  ");
						else
							printf(" ");
					}
					printf("\n");
				}
				else
				{
					for (int k = 0; k < w; k++)
					{
						for (int n = 0; n < leng; n++)
						{
							printf("%c",DIGIT[s[n] - '0'][i]);
							for (int m = 0; m < w; m++)
								printf(" ");
							printf("%c",DIGIT[s[n]-'0'][i+1]);
							if (n != leng - 1)
								printf(" ");
						}
						printf("\n");
					}
					i++;
				}
		}
		printf("\n");
	}

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