Codeforces Gym 100286I iSharp 水题
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 水题的更多相关文章
- Codeforces Gym 100286I iSharp 模拟
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- CodeForces Gym 100685C Cinderella (水题)
题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- UVaLive 6591 && Gym 100299L Bus (水题)
题意:略. 析:不解释,水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces 534B Covered Path (水题)
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
随机推荐
- 解决Jsoup网页抓取过程中需要cookie的问题
最近在做城觅网的信息抓取,发现城觅网上海与北京的url是一样的.那怎样才确定信息的来源呢?折腾了半天,才发现城觅网是使用cookie的,如果你把网站的cookie禁用了,就无法在上海与北京之间切换了. ...
- HTTP请求中浏览器的缓存机制
摘要:在Web开发过程中,我们可能会经常遇到浏览器缓存的问题.本文作者详细解释了浏览器缓存的机制,帮助读者更深层次的认识浏览器的缓存. 流程 当资源第一次被访问的时候,HTTP头部如下 (Reques ...
- POJ 2159 Ancient Cipher
题意:被题意杀了……orz……那个替换根本就不是ASCII码加几……就是随机的换成另一个字符…… 解法:只要统计每个字母的出现次数,然后把数组排序看相不相同就行了…… 代码: #include< ...
- [Everyday Mathematics]20150108
设 $f$ 在 $(a,b)$ 上 $n+1$ 次可导, 且 $$\bex \ln\frac{f(b)+f'(b)+\cdots+f^{(n)}(b)}{f(a)+f'(a)+\cdots+f^{(n ...
- .net-C#代码判断
ylbtech-doc:.net-C#代码判断 C#代码判断 1.A,C#代码判断返回顶部 01.{ C#题目}public static void Main(string[] args){ ...
- XAMPP:访问phpmyadmin出错的解决方案
来源:http://www.ido321.com/1246.html XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建 XAMPP 软件站集成软件包,轻巧,用起来很方便.它提 ...
- 时间,闰秒,及NTP
1.时间 格林尼治时间 GMT,以地球自转为准的时间,也叫世界时UT,但是由于自转速度会变化,所以后来不被作为标准. 世界协调时UTC,以原子钟为准,现在时间校准的标准就是原子钟. 2.闰秒 是指地球 ...
- [转]python起步之卡尔曼滤波
原文地址:http://www.niwozhi.net/demo_c65_i50946.html 关于卡尔曼滤波的理论这里不打算讲了,就是那个5个基本的公式,这里直接给出公式: 公式1:X(k|k-1 ...
- Java处理InterruptedException异常小结
对于InterruptedException,一种常见的处理方式是捕捉它,然后什么也不做(或者记录下它,不过这也好不到哪去).不幸的是,这种方法忽略了这样一个事实:这期间可能发生中断,而中断可能导致应 ...
- aspose.cell制作excel常见写法
//设置Excel的基本格式信息 Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[]; St ...