Marvelous Mazes

F - Marvelous Mazes

Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

Submit Status Practice UVA 445

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[150];
    int sum=0;
    while(gets(s))
    {
        int len=strlen(s);
        for(int i=0;i<len;i++)
        {
            if(s[i]>=‘0‘&&s[i]<=‘9‘)
            {
                sum+=s[i]-‘0‘;
            }
            else if(s[i]==‘!‘)
            {
                cout<<endl;
            }
            else if(s[i]==‘b‘)
            {
                for(int j=0;j<sum;j++)
                    cout<<‘ ‘;
                sum=0;
            }
            else
            {
                for(int j=0;j<sum;j++)
                {
                    cout<<s[i];
                }
                sum=0;
            }

        }
        cout<<endl;

    }
}

这里读取说的比较高级,但是用一个gets就解决了,因为它可以读取\n,水

时间: 2024-08-06 11:17:09

Marvelous Mazes的相关文章

UVa 445 - Marvelous Mazes

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=386 题目:给出一串包含A-Z,数字,*和空格的字符串,如果是!则输出换行,如果是b则输出空格,如果字符前有一个数字,则输出数字个字符,如果字符前有连续多个数字,则输出多个数字和的个数的字符. 思路:主要是注意多个连续数字的情况,将前面多个数字相加. 1 #i

UVa445 - Marvelous Mazes

题意:给出一个字符串,由数字.大写字母.*  .和b组成,当s[i]=='b'时,输出换行:当是数字时,如s[i]=2,s[i+1]='T',连续输出两个T:如果出现连续数字,则输出这些连续数字的和个字母,如11A,则输出AA. #include<stdio.h> #include<string.h> int main() { char s[140]; int i,j,sum,len; while(gets(s)!=NULL){ len=strlen(s); sum=0; for(

UVA_445:Marvelous Mazes

Language:C++ 4.8.2 #include<stdio.h> #include<string.h> #include<ctype.h> int main(void) { char str[140]; int sum; while(1) { if(fgets(str, sizeof(str), stdin) == NULL) break; if(str[0] == '\n') { printf("\n"); continue; } else

Marvelous Mazes UVA - 445

#include<iostream> #include<stdio.h> #include<string> #include<cstring> #define maxn 150 using namespace std; char mapn[maxn][maxn]; int main() { char str[150]; while(gets(str)!=NULL) { int sum; for(int i=0;i<strlen(str);) { sum

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

Marvelous Designer 3 Enterprise 1.4.0.7014 Win32_64 2CD三维服装设计

Marvelous Designer 3 Enterprise 1.4.0.7014 Win32_64 2CD三维服装设计Marvelouss Designer 3是韩国CLO Virtual Fashion公司开发的专业的三维服装设计软件,目前在世界各地很多设计师都开始使用这款软件.Marvelous Designer拥有非常直观的服装图案设计功能,你完全可以依据你的喜好,设计理念设计出属于你的风格.软件支持折线,绘制自由 曲线和三维立体裁剪同步互动设计,任何形式的修改会立即反映在3D实时立体

Marvelous Designer 服装设计与模拟

制作真实的角色衣服是CG动画中一项很具有挑战性的工作,是角色开发过程中非常重要的一步.它可以体现角色在故事中的性格,在技术发达的今天,制作一件虚拟衣服很容易.我们可以使用正确的工具发挥想象力在很短的时间内就能创作出真实的衣服. 说到这里,大家一定会想到Marvelous Designer(MD)这款优秀的服装设计与模拟软件.它是依据真实世界的服装缝合样式生成衣服,软件的界面设计非常友好,非常容易上手. 无论你是角色艺术家,还是VFX艺术家,还是角色TD更或者是一位概念设计艺术家,MD都是你最佳的

UVAlive 5796 Hedge Mazes

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3807 题意:给一个图,有R个点C条边,会进行Q次询问.每次询问两个点u,v之间有没有为一条路径相联. 题解:如果两个点只有唯一一条路径,那么它们之间的路径里的边就要是桥,并且需要在同一联通块上. 1 #include <iostream> 2 #include &

CodeForce 377 A mazes(dfs+连通性问题)

Pavel 喜欢网格迷宫.一个网格迷宫是一个 n × m 的长方形迷宫,其中每个单元格要么是空白的,要么是墙体.您可以从一个单元格走到另一个单元格,只要两个单元格均是空白的,且拥有一条公共的边. Pavel 绘制了一个网格迷宫,包含的全部空白单元格形成了一个连通区域.换言之,您可以从任何一个空白的单元格,走到其它任意的空白单元格.Pavel 的迷宫如果墙体太少,他就不喜欢这个迷宫.他希望将 k 个空白的单元格转换为墙体,使得剩余的全部单元格仍然能够形成一个连通区域.请帮助他实现这个任务. 输入