博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 445 - Marvelous Mazes
阅读量:4981 次
发布时间:2019-06-12

本文共 2193 字,大约阅读时间需要 7 分钟。

 Marvelous Mazes

Your mission, if you decide to accept it, is to create a maze drawing program. A maze will consist of the alphabetic characters A-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
题意:
给出一个字符串,由数字、大写字母、*  、和b组成,当s[i]=='b'时,输出换行;当是数字时,如s[i]=2,s[i+1]='T',连续输出两个T;如果出现连续数字,则输出这些连续数字的和个字母,如11A,则输出AA。
#include
#include
int main(){ char s[140]; int i,j,sum,len; while(gets(s)!= NULL) { len=strlen(s); sum=0; for(i=0;i
='0'&&s[i]<='9') /*如果是数字*/ sum+=s[i]-'0'; /*求输出个数*/ else { if(s[i]=='!') /*换行*/ printf("\n"); for(j=sum;j>0;j--) { if(s[i]=='b') /*输出空格*/ printf(" "); else /*输出字母或 * */ printf("%c",s[i]); } sum=0; /*记得输出后清零*/ } } printf("\n"); } return 0;}

 

转载于:https://www.cnblogs.com/dyllove98/p/3184774.html

你可能感兴趣的文章
POJ1611
查看>>
个人书单
查看>>
MySql下载地址
查看>>
springmvc学习笔记---idea创建springmvc项目
查看>>
SQL Server 大数据量插入和索引关系
查看>>
无旋Treap - BZOJ1014火星人 & 可持久化版文艺平衡树
查看>>
【微信小游戏实战】零基础制作《欢乐停车场》一、游戏设计
查看>>
【uoj#315/bzoj4943】[NOI2017]蚯蚓排队 Hash
查看>>
Docker容器部署tomcat出现中文乱码
查看>>
vue项目安装
查看>>
Validtion
查看>>
C++的发展方向是对的嘛?
查看>>
一个程序员的爱情宣言--程序员的情书
查看>>
yui问题
查看>>
c++ STL stack容器成员函数
查看>>
idea maven install 卡住,无报错排查。
查看>>
AFNetworking 3.0迁移指南
查看>>
mysql 内置功能 存储过程 创建有参存储过程
查看>>
bash变量常用技巧
查看>>
Git reflog
查看>>