HDU3257 ZOJ3247 Hello World!【打印图案+位运算】

232 篇文章 0 订阅
13 篇文章 1 订阅

Hello World!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 779    Accepted Submission(s): 313


Problem Description
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?
 

Input
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...
 

Output
For each test case, print the case number in the first line, then followed by a blank line.
After that, print all T characters. Use a single blank column of spaces between two consecutive characters. Each line should have exactly 6C-1 character (again, don't ask me why).
Don't forget to print another blank line after the output of each test case.
 

Sample Input
 
 
2117F 08 08 08 7F38 54 54 54 1800 41 7F 40 0000 41 7F 40 0038 44 44 44 3800 00 00 00 003F 40 38 40 3F38 44 44 44 387C 08 04 04 0800 41 7F 40 0038 44 44 48 7F514 08 3E 08 1404 02 01 02 0440 40 40 40 4004 02 01 02 0414 08 3E 08 14
 
Sample Output
 
 
Case 1:# # ## ## # # ## ## # # # # # # ## # ### # # ### # # ### # ## # ## ###### # # # # # # # # # # # ## # # # ### # ##### # # # # # # # # # # # # ## # # # # # # # # # # # # # # ## # ### ### ### ### # # ### # ### ####Case 2: # # # # # # # # # # # # # # # # # # ### ### # # # # # # # # #####
 

Source


问题链接HDU3257 ZOJ3247 Hello World!

问题简述:参见上述链接。

问题分析:图案输出,关键在于读懂题意。

程序说明

  需要注意16进制数的输入方法。

  需要注意位运算。

  需要注意用方便的数据表示(这里用一维数组比较方便)。

  需要注意循环控制条件。

题记:(略)


AC的C++语言程序如下:

/* HDU3257 ZOJ3247 Hello World! */

#include <iostream>
#include <cstdio>

using namespace std;

const int N = 7;
const int ROW = 80;
const int COL = 5;
int a[ROW * COL];

int main()
{
    int t, c;

    scanf("%d", &t);
    for(int k=1; k<=t; k++) {
        scanf("%d", &c);
        for(int i=0; i<c*COL; i++)
                scanf("%x", &a[i]);

        printf("Case %d:\n\n", k);
        for(int i=0; i<N; i++) {
            int bit = (1 << i);
            for(int j=0; j<c*COL; j++) {
                if(j != 0 && j % COL == 0)
                    printf(" ");
                printf("%c", ((a[j] & bit) ? '#' : ' '));
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值