HDU 3257 Hello World!

题意:举一个例子,7F(十六进制)=127(十进制)=1111111(二进制),若二进制第i位是1,则第col列的第i行是#,若二进制位是0,则第col列的第i行是space,注意PE,最后一个单词右边没有space,然后单词高7,每个例子之后空一行。

#include<stdio.h>
#include<string.h>
int map_num[85][10];
char map_out[10][550];
int Get_num(char a){
	if(a >= '0'&&a <= '9'){
		return a-'0';
	}
	if(a == 'A'){
		return 10;
	} 
	if(a == 'B'){
		return 11;
	}
	if(a == 'C'){
		return 12;
	}
	if(a == 'D'){
		return 13;
	}
	if(a == 'E'){
		return 14;
	}
	if(a == 'F'){
		return 15;
	}
}
int Get_dec(char a , char b){
	return Get_num(a)*16 + Get_num(b);
} 
int main(){
	int T,ca = 1;
	scanf("%d",&T);
	while(T--){
		int C;
		scanf("%d",&C);
		for(int i = 1;i <= C;++i){
			for(int j = 1;j <= 5;++j){
				char inPutstr[3];
				scanf("%s",inPutstr);
				map_num[i][j] = Get_dec(inPutstr[0],inPutstr[1]);
			}
		}
		memset(map_out,'\0',sizeof(map_out));
		for(int i = 1;i <= C; ++i){
			int col = 6*i-6;
			for(int j = 1;j <= 5; ++j){
				for(int z = 0 ;z <= 6; ++z){
					if(map_num[i][j]&1<<z){
						map_out[z][col] = '#';
					}
					else{
						map_out[z][col] = ' ';
					}
				}
				col++;
			}
			for(int j = 0;j <= 6; ++j){
				if(i != C) map_out[j][col] = ' ';
 			}
		}
		
		printf("Case %d:\n\n",ca++);
		for(int i = 0;i <= 6; ++i){
			for(int j = 0; j <= 6*C-2; ++j){
				printf("%c",map_out[i][j]);
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/triple_wdf/article/details/80069781
今日推荐