Marvelous Mazes
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Description
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 11X21b1X
4X1b1X
Sample Output
T TTTTT
T T TT
T T TT
T T T
TTT T
T T T
TTTTT*T XX X
XXXX X
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[];
int sum=;
while(gets(s))
{
int len=strlen(s);
for(int i=;i<len;i++)
{
if(s[i]>=''&&s[i]<='')
{
sum+=s[i]-'';
}
else if(s[i]=='!')
{
cout<<endl;
}
else if(s[i]=='b')
{
for(int j=;j<sum;j++)
cout<<' ';
sum=;
}
else
{
for(int j=;j<sum;j++)
{
cout<<s[i];
}
sum=;
} }
cout<<endl; }
}
这里读取说的比较高级,但是用一个gets就解决了,因为它可以读取\n,水
Marvelous Mazes的更多相关文章
- UVa 445 - Marvelous Mazes
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
- Marvelous Mazes UVA - 445
#include<iostream> #include<stdio.h> #include<string> #include<cstring> #def ...
- UVA_445:Marvelous Mazes
Language:C++ 4.8.2 #include<stdio.h> #include<string.h> #include<ctype.h> int main ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- 【索引】Volume 0. Getting Started
AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 0. Getting Started 10055 - Hashmat the Brav ...
- TOJ 2017: N-Credible Mazes
2017: N-Credible Mazes Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByteTotal Subm ...
- CodeForce 377 A mazes(dfs+连通性问题)
Pavel 喜欢网格迷宫.一个网格迷宫是一个 n × m 的长方形迷宫,其中每个单元格要么是空白的,要么是墙体.您可以从一个单元格走到另一个单元格,只要两个单元格均是空白的,且拥有一条公共的边. Pa ...
- History lives on in this distinguished Polish city 2017/1/4
原文 History lives on in this distinguished Polish city Though it may be ancient. KraKow, Poland, is a ...
- SVM(支持向量机)的一点理解
最近有被问到SVM的问题,不懂装懂,羞愧不已.百度有很多深入浅出介绍SVM的文章,我就不赘述了,这里写一点自己肤浅的理解. SVM的核心思想是把求解低维空间上的高维分类器转化为求解高维函数空间上的线性 ...
随机推荐
- mysql 多表联合更新
UPDATE mall_order moLEFT JOIN mall_order_goods mog ON mo.id = mog.order_idSET mo.ratio=0.08WHERE mog ...
- 图像特征提取:Sobel边缘检测
前言 点和线是做图像分析时两个最重要的特征,而线条往往反映了物体的轮廓,对图像中边缘线的检测是图像分割与特征提取的基础.文章主要讨论两个实际工程中常用的边缘检测算法:Sobel边缘检测和Canny边缘 ...
- Java数据库ResultSet转json实现
现在有很多json相关的Java工具,如json-lib.gson等,它们可以直接把JavaBean转换成json格式. 在开发中,可能会从数据库中获取数据,希望直接转成json数组,中间不通过bea ...
- linux下proc里关于磁盘性能的参数
我 们在磁盘写操作持续繁忙的服务器上曾经碰到一个特殊的性能问题.每隔 30 秒,服务器就会遇到磁盘写活动高峰,导致请求处理延迟非常大(超过3秒).后来上网查了一下资料,通过调整内核参数,将写活动的高峰 ...
- 【云计算】Docker删除名称为none的Image镜像
先上删除命令: docker images|grep none|awk '{print $3 }'|xargs docker rmi docker强制批量删除none的image镜像 真是有段时间 ...
- Java 7 的7个新特性
1.对集合类的语言支持:(??) 2.自动资源管理: 3.改进的通用实例创建类型推断:(??) 4.数字字面量下划线支持:(√) 5.switch中使用string:(√) 6.二进制字面量:(√) ...
- tcp/ip程序
#include<stdio.h> #include<stdlib.h> #include<errno.h> #include<string.h> #i ...
- 【USACO】packrec
这道题卡了很久,开始没读清楚题,没看到题目中给的6个组合是仅可能的组合,一直自己想有多少种组合方式.后来才发现,于是就想到写遍历.我想的是,这六种情况下,每个位置摆哪个矩形是不确定的,于是可以对方块的 ...
- HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)
Sum Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64u Submit Status ...
- Material Design入门(三)
本文主要包括 CollapsingToolbarLayout实现滚动动画效果 ViewPager+tabLayout实现左右类Tab效果 控件介绍 这次需要用到得新控件比较多,主要有以下几个: Coo ...