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 = 0 , a2 = 0 , a3 = 0;void GetName()
{name.clear();sign.clear();for(int i = 0 ; i < temp.size() ; ++ i){if ( (temp[i] <= 'Z' && temp[i] >= 'A' ) || (temp[i] <= 'z' && temp[i] >= 'a') ){name.pb(temp[i]);}elsesign.pb(temp[i]);}reverse(sign.begin(),sign.end());for(int i = 0 ; 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 = 0 ; i< str.size() ; ++ i){if (str[i] == ' '){sb = str.substr(0,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+1,i-pre-1);GetName();cout << sb << sign << " "<< name << ';'<<endl;i ++;pre = i;}}return 0;
}

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

题解

模拟一下就好了

代码:

Codeforces Gym 100286I iSharp 水题相关推荐

  1. Codeforces Gym 100286I iSharp 模拟

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

  2. codeforces 1060a(思维水题)

    Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...

  3. CodeForces - 1287B Hyperset(暴力水题)

    题目链接:点击查看 题目大意:给出"集合"的定义: 集合中必须有三个元素 每个元素的每个特征值必须全部相同或者全部不同,不能存在两者相同但与第三者不同 现在给出n个元素以及m个特征 ...

  4. CodeForces 931C Laboratory Work 水题,构造

    *这种题好像不用写题解... 题意: 一个人要改动别人的实验记录,实验记录记录是一个集合 实验记录本身满足:$max(X)-min(X)<=2$ 改动结果要求: 1.新的集合平均值和之前的一样 ...

  5. 【CodeForces - 1066A~E】水题,模拟(有技巧),思维,题意难懂的模拟,二进制问题(有技巧)

    A. 题目大意: x坐标上1~L有L个点都是整数,每v个长度就有一个灯亮着,但是有 [ l , r ] 这段区间上有列火车挡住了,问你能看到多少亮灯. 解题报告: 大水题啊,找几个样例就会发现需要特殊 ...

  6. CodeForces - 13A Numbers【水题】

    题目链接:https://codeforces.com/contest/13/problem/A 暴力 #include <iostream> using namespace std; i ...

  7. Educational Codeforces Round 30 A[水题/数组排序]

    A. Chores time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  8. CodeForces - 1042C (emmmmmm水题)

    You are given an array aa consisting of nn integers. You can perform the following operations with i ...

  9. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

最新文章

  1. 数据库结构Sqlite与CoreData
  2. 赛迪155页PPT中国“新基建”发展研究报告!
  3. MyBatis子查询
  4. ppt倒计时3分钟_PPT做的又慢又丑?花3分钟学会这5个PPT神技巧,快速做出好看PPT...
  5. 对用户数据进行简单的管理用,C++实现几个字符串的字典序排序
  6. github/gitlab同时管理多个ssh key
  7. 非常简洁漂亮的博客导航页带自适应
  8. public 返回一数组_数组:滑动窗口拯救了你
  9. python如何实现日期格式的转换_python开发中时间格式如何转化?
  10. Kali 更新失败 签名无效
  11. 华为、小米手机收不到推送消息的LOG
  12. MindSpore:自然语言处理(NLP)—分词技术
  13. postman导出,断言,批量执行
  14. 【实例间对比】ICE: Inter-instance Contrastive Encoding for Unsupervised Person Re-identification论文笔记
  15. Flink【优质】面试
  16. 用户增长分析——用户分群分析
  17. 用例测试(三)——边界值分析法
  18. 微软必应词典UWP -2017春
  19. Android获取网络图片的宽高
  20. KKT condition --- Karush–Kuhn–Tucker conditions

热门文章

  1. ITK:二进制或两张图片
  2. ITK:将蒙版的反面应用于图像
  3. VTK:Texture之TexturedSphere
  4. VTK:Snippets之WriteImage
  5. C语言打印链表的中间节点的算法(附完整源码)
  6. QT的QCategoryAxis类的使用
  7. 经典C语言程序100例之三七
  8. python求两数最大公因数_『用python求俩个数的最大公约数和最小公倍数』
  9. 53.垃圾回收算法的实现原理、启动Java垃圾回收、Java垃圾回收过程、垃圾回收中实例的终结、对象什么时候符合垃圾回收的条件、GC Scope 示例程序、GC OutOfMemoryError的示例
  10. B13_NumPy数学函数(三角函数,舍入函数)