hdu 3257 Hello World!

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

今天又研究了下,懂了= =。。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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值