2013秋13级预备队集训练习1 H - Marvelous Mazes

来源:互联网 发布:网络管理工具有哪些 编辑:程序博客网 时间:2024/06/04 17:51
Download as PDF


 Marvelous Mazes 

Your mission, if you decide to accept it, is to create a maze drawing program. A maze will consist of the alphabetic charactersA-Z, * (asterisk), and spaces.

Input and Output

Your program will get the information for the mazes from the input file. This file will contain lines of characters which your program must interpret to draw a maze. Each row of the maze will be described by a series of numbers and characters, where the numbers before a character tell how many times that character will be used. If there are multiple digits in a number before a character, then the number of times to repeat the character is the sum of the digits before that character.

The lowercase letter "b" will be used in the input file to represent spaces in the maze. The descriptions for different rows in the maze will be separated by an exclamation point (!) or by an end of line.

Descriptions for different mazes will be separated by a blank line in both input and output. The input file will be terminated by an end of file.

There is no limit to the number of rows in a maze or the number of mazes in a file, though no row will contain more than 132 characters.

Happy mazing!

Sample Input

1T1b5T!1T2b1T1b2T!1T1b1T2b2T!1T3b1T1b1T!3T3b1T!1T3b1T1b1T!5T1*1T 11X21b1X4X1b1X

Sample Output

T TTTTTT  T TTT T  TTT   T TTTT   TT   T TTTTTT*T XX   XXXXX X
#include<stdio.h>#include<string.h>int main(){    int i , j , a = 0 ;    char str[133];    while(gets(str)!=NULL)    {        for(i = 0 ; str[i]!='\0' ; i++)        {            if(str[i]=='!') printf("\n");if(str[i] >= '0' && str[i]<= '9')a = a + str[i] - '0';else{for(j = 0 ; j < a ; j++){if(str[i]=='b')printf(" ");elseprintf("%c", str[i]);}a = 0;}        }        printf("\n");    }    return 0 ;}

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 小米手机刷机后激活不了帐号怎么办 魅蓝note5卡顿怎么办 魅蓝note5卡了怎么办 魅蓝note5很卡怎么办 魅蓝note5锁了怎么办 荣耀9开不开机怎么办 4s更新后用不了怎么办 魅蓝3开不了机怎么办 手机不支持联通4g网络怎么办 华为手机出现emui界面怎么办 华为畅玩4x内存不足怎么办 手机电源键掉了怎么办 手机电源键坏了怎么办 小米5s听筒声音小怎么办 荣耀8电源键失灵怎么办 华为荣耀3c卡怎么办 大王卡是2g网络怎么办 联通停用2g副卡怎么办 华为荣耀8忘记解锁密码怎么办 华为手机内存满了怎么办 华为手机无限重启怎么办 华为3c重启怎么办 荣耀6 无限重启怎么办 手机进水无法开机了怎么办 华为手机不停重启怎么办 华为手机反复重启怎么办 酷派电池不耐用怎么办 美图手机充电慢怎么办 酷派b770太卡怎么办 酷派手机出现无命令怎么办 华为荣耀4x卡怎么办 华为手机图案解锁忘了怎么办 xp电脑读不起u盘怎么办 在外国玩王者卡怎么办 华为p7忘记解锁密码怎么办 华为荣耀4x存储空间不足怎么办 红米4a内存不够怎么办 华为h60开不了机怎么办 华为荣耀4c内存不足怎么办 华为4c运行内存不足怎么办 华为手机总是显示内存不足怎么办