首页 > ACM题库 > HDU-杭电 > HDU 3257-Hello World!-字符串处理-[解题报告]HOJ
2014
03-13

HDU 3257-Hello World!-字符串处理-[解题报告]HOJ

Hello World!

问题描述 :

Your task is to print … er … "Hello World" … in a fantastic way — using a beautiful font.

I’ve sent you a nice font for you to use, but I’m too busy to tell you how. Can you help yourself?

输入:

The first line contains a single integer T (T <= 20), the number of test cases.
Each case begins with an integer C (1 <= C <= 80) in a single line, then each of the following C lines contains five two-digit numbers in hex (letters will be in uppercase). Don’t ask me what they mean, I’m too busy…

输出:

The first line contains a single integer T (T <= 20), the number of test cases.
Each case begins with an integer C (1 <= C <= 80) in a single line, then each of the following C lines contains five two-digit numbers in hex (letters will be in uppercase). Don’t ask me what they mean, I’m too busy…

样例输入:

2
11
7F 08 08 08 7F
38 54 54 54 18
00 41 7F 40 00
00 41 7F 40 00
38 44 44 44 38
00 00 00 00 00
3F 40 38 40 3F
38 44 44 44 38
7C 08 04 04 08
00 41 7F 40 00
38 44 44 48 7F
5
14 08 3E 08 14
04 02 01 02 04
40 40 40 40 40
04 02 01 02 04
14 08 3E 08 14

样例输出:

Case 1:

#   #        ##    ##               #   #              ##       #
#   #         #     #               #   #               #       #
#   #  ###    #     #    ###        #   #  ###  # ##    #    ## #
##### #   #   #     #   #   #       # # # #   # ##  #   #   #  ##
#   # #####   #     #   #   #       # # # #   # #       #   #   #
#   # #       #     #   #   #       # # # #   # #       #   #   #
#   #  ###   ###   ###   ###         # #   ###  #      ###   ####

Case 2:

        #           #        
  #    # #         # #    #  
# # # #   #       #   # # # #
 ###                     ### 
# # #                   # # #
  #                       #  
            #####            

以前看过,没啥想法,不知道是干嘛的 = =。。。

今天又研究了下,懂了= =。。7F化成2进制是1111111,也就是第一列是7个#。。。无语

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <string>
#include <algorithm>
#define MID(x,y) ( ( x + y ) >> 1 )
#define L(x) ( x << 1 )
#define R(x) ( x << 1 | 1 )
#define BUG puts("here!!!")
#define STOP system("pause")

using namespace std;

char s[10][500];

int to16(char *s)
{
	int ans = 0;
	if( isdigit(s[0]) )
		ans = s[0] - '0';
	else
		ans = s[0] - 'A' + 10;
	ans *= 16;
	if( isdigit(s[1]) )
		ans += s[1] - '0';
	else
		ans += s[1] - 'A' + 10;	
	return ans;
}

int main()
{
	int ncases, n, r, ind = 1;
	
	char str[5];
	scanf("%d", &ncases);
	
	while( ncases-- )
	{
		scanf("%d", &n);
		
		for(int i=0; i<7; i++)
			for(int k=0; k<500; k++)
				s[i][k] = ' ';
				
		for(int i=0; i<n; i++)
		{
			r = i*6;
			for(int k=0; k<5; k++)
			{
				scanf("%s", str);
				int p = to16(str);
				for(int l=0; l<7; l++)
				{
					if( p % 2 == 1 )
						s[l][r] = '#';
					else
						s[l][r] = ' ';
					p /= 2;
				}
				r++;
			}
		}
		printf("Case %d:\n\n", ind++);
		for(int i=0; i<7; i++)
		{
			for(int k=0; k<6*n-1; k++)
				printf("%c",s[i][k]);
			printf("\n");
		}
		printf("\n");
	}

return 0;
}

参考:http://blog.csdn.net/zxy_snow/article/details/6718553