codeforces gym 100286 I iSharp (字符串模拟)
给定一个字符串。输入是int& a*[]&, b, c*;
输出是
int&&[]* a;
int& b;
int&* c;
输入格式里逗号后面一定有个空格,把字母后面的符号逆序拿到前面来,按每个逗号分隔输出即可。
注意输出格式一定是定义类型+符号+空格+字母或字符串+分号。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
char s[];
char c[],cnt1=;
int main()
{
freopen("isharp.in","r",stdin);
freopen("isharp.out","w",stdout);
while(gets(s))
{
memset(c,,sizeof(c));
int len=strlen(s);
for(int i=;i<len;i++)
{
if(s[i]!=' ')
c[i]=s[i];
else
{
cnt1=i;
break;
}
}
//cout<<c<<endl;;
int ss=cnt1+;
int ee=-;
for(int i=cnt1+;i<len;i++)
{
if(s[i]!=','&&s[i]!=';')
continue;
else
{
ee=i-;
cout<<c;
for(int j=ee;j>=ss;j--)
{
if(!((s[j]>='a'&&s[j]<='z')||(s[j]>='A'&&s[j]<='Z')))
{
if(s[j]!=']')
printf("%c",s[j]);
else
{
printf("[]");
j--;
}
}
else
{
bool first=true;
for(int k=ss;k<=j;k++)
{
if(!((s[k]>='a'&&s[k]<='z')||(s[k]>='A'&&s[k]<='Z')))
printf("%c",s[k]);
else if(first)
{
printf(" %c",s[k]);
first=false;
}
else
printf("%c",s[k]);
}
printf(";\n");
ss=ee+;
i+=;
break;
}
}
}
}
}
return ;
}
// int& a*[]&, b, c*;
codeforces gym 100286 I iSharp (字符串模拟)的更多相关文章
- Codeforces Gym 100338B Spam Filter 字符串哈希+贝叶斯公式
原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-an ...
- codeforces 723B Text Document Analysis(字符串模拟,)
题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...
- Codeforces Gym 100269B Ballot Analyzing Device 模拟题
Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...
- Codeforces Round #528-A. Right-Left Cipher(字符串模拟)
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- codeforces gym 101164 K Cutting 字符串hash
题意:给你两个字符串a,b,不区分大小写,将b分成三段,重新拼接,问是否能得到A: 思路:暴力枚举两个断点,然后check的时候需要字符串hash,O(1)复杂度N*N: 题目链接:传送门 #prag ...
- codeforces gym 100286 H - Hell on the Markets (贪心算法)
题目链接 题意:n个数分别为a[i],问是否存在一组对应的b[i],b[i]=1 || b[i]=-1,使得ai*bi的n项和为0. 题解: 先证明一个结论吧,对于1≤ai≤i+1,前面ai个数一定可 ...
- Codeforces Gym 100286I iSharp 模拟
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...
- Codeforces Round #425 (Div. 2) B. Petya and Exam(字符串模拟 水)
题目链接:http://codeforces.com/contest/832/problem/B B. Petya and Exam time limit per test 2 seconds mem ...
- Codeforces Gym 100286J Javanese Cryptoanalysis 傻逼暴力
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...
随机推荐
- php防注入
引发 SQL 注入攻击的主要原因,是因为以下两点原因: 1. php 配置文件 php.ini 中的 magic_quotes_gpc选项没有打开,被置为 off 2. 开发者没有对数据类型进行检查和 ...
- mybatis 基础1(动态代理)
我目前使用的是mybatis 3.3.0版本. 可使用 1.xml文本, 2.dao类, 3.sqlSession.getMapper(Class<T> type), 生成sql类, 原理 ...
- hadoop安装实战(mac实操)
集群环境配置参考(http://blog.csdn.net/zcf1002797280/article/details/49500027) 参考:http://www.cnblogs.com/liul ...
- activti表结构
1.结构设计 1.1. 逻辑结构设计 Activiti使用到的表都是ACT_开头的. ACT_RE_*: ’RE’表示repository(存储),RepositoryService接口所操作的 ...
- 给一系列的div中的第一个添加class
$(".lb:first").addClass("active")
- js字符串与16进制互相转换
// \x65\x76\x61\x6c是否启用\x加密 <script type="text/javascript"> function JavaDe() { var ...
- Java 7 Concurrency Cookbook 翻译 第一章 线程管理之六
十一.处理线程组中的未控制异常 每种编程语言一个很重要的特性就是其所提供的用来处理程序中错误情况的机制.Java语言和其他的现代语言一样,是提供了异常机制来处理对象程序中的错误.Java提供了很多的类 ...
- 回复《我要阻止做java开发的男朋友去创业型公司工作吗?》园友问题
真的非常开心能收到这么多园友的关心,看到这么多的回复顿感身边处处充满爱.也非常感谢大家踊跃的帮我出谋划策,小女子在此有礼了! 我先来回答一下性别的问题(前面已经暴露了……),我是前端程序媛.大三时和男 ...
- Android四种基本布局(LinearLayout \ RelativeLayout \ FrameLayout \ TableLayout)
------------------------------------------LinearLayout---------------------------------------------- ...
- ubuntu 出现g++ : Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed
Ubuntu 你可以安装搜狗输入法也可以使用sunpingyin,看个人爱好. 唯一要注意的是,不能把系统的更新关了,否则会出现一大堆的问题,连g++都无法安装. 在设置里面: 我以前有一个很不好的习 ...