PAT-2019年冬季考试-甲级-7-1 Good in C (20分)

该博客介绍了PAT 2019年冬季考试中的一道题目,要求使用C语言根据给定的26个字母7x5矩阵,将输入的单词以矩阵形式输出。博客提供了输入输出规格、样例及解题思路,强调了处理输入中的空格和单词分隔,以及正确输出字母和单词间格式的要求。博主在考场上遇到问题,最终采用字符数组手动实现解决方案。
摘要由CSDN通过智能技术生成

When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows?

Input Specification:

Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in a 7×5 matrix of C’s and .'s. Then a sentence is given in a line, ended by a return. The sentence is formed by several words (no more than 10 continuous capital English letters each), and the words are separated by any characters other than capital English letters.
It is guaranteed that there is at least one word given.

Output Specification:

For each word, print the matrix form of each of its letters in a line, and the letters must be separated by exactly one column of space. There must be no extra space at the beginning or the end of the word.
Between two adjacent words, there must be a single empty line to separate them. There must be no extra line at the beginning or the end of the output.

Sample Input:

#csdn蜜汁不能折叠代码,这段太长了…大概就是26组7*5矩阵,比如A:
…C…
.C.C.
C…C
CCCCC
C…C
C…C
C…C
#blablablablablabla
#最后一行是给出的字符串:
HELLO~WORLD!

Sample Output:

C…C CCCCC C… C… .CCC.
C…C C… C… C… C…C
C…C C… C… C… C…C
CCCCC CCCC. C… C… C…C
C…C C… C… C… C…C
C…C C… C… C… C…C
C…C CCCCC CCCCC CCCCC .CCC.

C…C .CCC. CCCC. C… CCCC.
C…C C…C C…C C… C…C
C…C C…C CCCC. C… C…C
C.C.C C…C CC… C… C…C
CC.CC C…C C.C… C… C…C
C…C C…C C…C. C… C…C
C…C .CCC. C…C CCCCC CCCC.

思路&分析

输入26个字母的75的矩阵点状图,根据输入的字符串来输出点状格式的单词。
用二维数组(26
7)来存储每一行的字符串,整行读取,分割字符串成单词,三重循环输出每个单词的7行。

注意点:

  1. 输入为一整行,开头、中间、结尾都有可能有空格;
  2. 输入内容里的小写字母不算在单词内,也是作为分割单词的其它字符处理;
  3. 输出字母间的空格,单词间的空行;

提交代码(AC)

考场上不知为何getline(cin,str);总是报错…不得不手搓了一个按字符读取,用回char[]数组;

#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <string.h>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值