Problem I. iSharp
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86821#problem/I

Description

You are developing a new fashionable language that is not quite unlike C, C++, and Java. Since your language should become an object of art and fashion, you call it i # (spelled i-sharp). This name combines all the modern naming trends and also hints at how smart you are. Your language caters for a wide auditory of programmers and its type system includes arrays (denoted with “[]”), references (denoted with “&”), and pointers (denoted with “*”). Those type constructors can be freely combined in any order, so that a pointer to an array of references of references of integers (denoted with “int&&[]*”) is a valid type. Multiple variables in i # can be declared on a single line with a very convenient syntax where common type of variables is given first, followed by a list of variables, each optionally followed by additional variable-specific type constructors. For example, the following line: int& a*[]&, b, c*; declares variables a, b, and c with types “int&&[]*”, “int&”, and “int&*” correspondingly. Note, that type constructors on the right-hand sides of variables in i # bind to variable and their order is reversed when they are moved to the left-hand side next to type. Thus “int*& a” is equivalent to “int a&*”. However, you discover that coding style with multiple variable declarations per line is confusing and is outlawed in many corporate coding standards. You decide to get rid of it and refactor all existing i # code to a single variable declaration per line and always specify type constructor next to the type it refers to (instead of the right-hand side of variable). Your task it to write such refactoring too

Input

The input file contains a single line with a declaration of multiple variables in i #. The line starts with a type name, followed by zero, one, or more type constructors, followed by a space, followed by one or more variable descriptors separated by “,” (comma) and space, and terminated by “;” (semicolon). Each variable descriptor contains variable name, followed by zero, one, or more type constructors. Type name and variable names are distinct and consist of lowercase and uppercase English letters from “a” to “z” or “A” to “Z”. The line contains at most 120 characters and does not contain any extra spaces.

Output

Write to the output file a line for each variable declared in the input file. For each variable write its declaration on a single line in the same format as in the input file, but with all type constructors next to its type. Separate type with all type constructors from a variable name by a single space. Do not write any extra spaces.

Sample Input

int& a*[]&, b, c*;

Sample Output

int&&[]* a;
int& b;
int&* c;

HINT

题意

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <ctime>
#include <list>
typedef unsigned char byte;
#define pb push_back
#define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
#define local freopen("in.txt","r",stdin)
#define pi acos(-1) using namespace std;
string str;
string sb;
string temp;
string name;
string sign;
int a1 = , a2 = , a3 = ; void GetName()
{
name.clear();sign.clear();
for(int i = ; i < temp.size() ; ++ i)
{
if ( (temp[i] <= 'Z' && temp[i] >= 'A' ) || (temp[i] <= 'z' && temp[i] >= 'a') )
{
name.pb(temp[i]);
}
else
sign.pb(temp[i]);
}
reverse(sign.begin(),sign.end());
for(int i = ; i < sign.size() ; ++ i)
{
if (sign[i] == '[') sign[i] = ']';
else if(sign[i] == ']') sign[i] = '[';
}
} int main(int argc,char *argv[])
{
freopen("isharp.in","r",stdin);
freopen("isharp.out","w",stdout);
getline(cin,str);
int bg;
for(int i = ; i< str.size() ; ++ i)
{
if (str[i] == ' ')
{
sb = str.substr(,i);
bg = i;
break;
}
}
int pre = bg;
for(int i = bg ; i < str.size() ; ++ i)
{
if (str[i] == ',' || str[i] == ';')
{
temp.clear();
temp = str.substr(pre+,i-pre-);
GetName();
cout << sb << sign << " "<< name << ';'<<endl;
i ++;
pre = i;
}
}
return ;
}

题,然后倒着输出字符就好了

题解

模拟一下就好了

代码:

Codeforces Gym 100286I iSharp 水题的更多相关文章

  1. Codeforces Gym 100286I iSharp 模拟

    原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...

  2. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  3. CodeForces Gym 100685C Cinderella (水题)

    题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...

  4. codeforces 706A A. Beru-taxi(水题)

    题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...

  5. codeforces 569B B. Inventory(水题)

    题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  6. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  7. UVaLive 6591 && Gym 100299L Bus (水题)

    题意:略. 析:不解释,水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...

  8. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. CodeForces 534B Covered Path (水题)

    题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...

随机推荐

  1. 利用c#反射实现实体类生成以及数据获取与赋值

    转:http://hi.baidu.com/xyd21c/item/391da2fc8fb351c10dd1c8b8 原有的实体类成员逐个赋值与获取的方法弊端: 1.每次对实体类属性进行赋值时,都要检 ...

  2. 开启Ubuntu Linux下VirtualBox访问USB功能

    解决方法如下: 1.增加用户组usbfs sudo groupadd usbfs 2.查看usbfs用户组的gid cat /etc/group | grep usbfs usbfs:x:1002: ...

  3. 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(6)

    创建一个新文档(Creating a new document) 现在我们将尝试索引一些文档.对于我们的示例,让我们想象我们正在为我们的博客建立某种CMS.实体之一是博客的文章.使用JSON记法,在以 ...

  4. IOS 给图片添加水印 打印文字

    1.加文字   -(UIImage *)addText:(UIImage *)img text:(NSString *)text1  {           //get image width and ...

  5. C# 多线程传参 三种实例

    //using Thread to download files //1111111111111111 foreach (var str in listDownloadPdf) { //string ...

  6. ORA-15063: ASM discovered an insufficient number of disks for diskgroup "ASM,KEL"

    在启动ASM的时候报错,报错如下: SQL> startup ASM instance started Total System Global Area 130023424 bytes Fixe ...

  7. [iOS基础控件 - 7.0] UIWebView

    A.基本使用 1.概念 iOS内置的浏览器控件 Safari浏览器就是通过UIWebView实现的   2.用途:制作简易浏览器 (1)基本请求 创建请求 加载请求 (2)代理监听webView加载, ...

  8. [iOS UI进阶 - 3.0] 触摸事件的基本处理

    A.需要掌握和练习的 1.介绍事件类型2.通过按钮的事件处理引出view的事件处理3.响应者对象 --> UIResponder --> UIView4.view的拖拽* 实现触摸方法,打 ...

  9. Android流量监控 思路,想法

    1,开启一个服务,每5分钟跑动一次更新流量,用于能够准确记录流量         每一个小时,更新一次流量,用于清除非本月的流量 2,保存流量的时候,进行判断         a,若是数据库中保存的 ...

  10. Map 排序

    /** * 通过map 的 value 排序,并返回排序后的第一个条目 * * @param m 待排序集合 * @param desc true:降序排序,false:升序排序 * @return ...