题目链接

给定一个字符串。输入是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 (字符串模拟)的更多相关文章

  1. Codeforces Gym 100338B Spam Filter 字符串哈希+贝叶斯公式

    原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-an ...

  2. codeforces 723B Text Document Analysis(字符串模拟,)

    题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...

  3. Codeforces Gym 100269B Ballot Analyzing Device 模拟题

    Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...

  4. Codeforces Round #528-A. Right-Left Cipher(字符串模拟)

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  5. codeforces gym 101164 K Cutting 字符串hash

    题意:给你两个字符串a,b,不区分大小写,将b分成三段,重新拼接,问是否能得到A: 思路:暴力枚举两个断点,然后check的时候需要字符串hash,O(1)复杂度N*N: 题目链接:传送门 #prag ...

  6. 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个数一定可 ...

  7. Codeforces Gym 100286I iSharp 模拟

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

  8. 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 ...

  9. Codeforces Gym 100286J Javanese Cryptoanalysis 傻逼暴力

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

随机推荐

  1. codevs2171 棋盘覆盖

    题目描述 Description 给出一张n*n(n<=100)的国际象棋棋盘,其中被删除了一些点,问可以使用多少1*2的多米诺骨牌进行掩盖. 输入描述 Input Description 第一 ...

  2. AlwaysOn可用性组测试环境安装与配置(一)--SQL群集环境搭建

    一.测试环境介绍 1. 宿主使用工作站(HYPR-V)基本配置如下: 处理器:Intel(R) Core(TM) i5-4470 CPU @ 3.20GHz 3.20GHz 内存(RAM):8.00G ...

  3. OC第六节—— 继承与类别

    1.继承:    父类和子类的关系.    1.1 生活中的继承        父类           子类           父类              子类                 ...

  4. JSON格式转换(javascript)

    使用ajax从后台抓取数据后,如果有多个值,可以使用json传值. ajax例子如下,在返回的类型里面,可以是文本型(text),JSON格式(json),超文本类型(html),XML文件类型(xm ...

  5. xcode 插件

    http://www.cocoachina.com/ios/20160122/15080.html https://github.com/rickytan/RTImageAssets http://m ...

  6. ubutu安装搜狗

    1.下载deb文件 下载32位 wget "http://pinyin.sogou.com/linux/download.php?f=linux&bit=32" -O &q ...

  7. 制作自定义背景Button按钮、自定义形状Button的全攻略(转)

    在Android开发应用中,默认的Button是由系统渲染和管理大小的.而我们看到的成功的移动应用,都是有着酷炫的外观和使用体验的.因此,我们在开发产品的时候,需要对默认按钮进行美化.在本篇里,笔者结 ...

  8. 一种map容器遍历的方法

    遍历算法是一种很常见而且非常重要的算法,我们用map容器的时候可能用的比较多的是查找,我今天才第一次要用到遍历.下面举个例子就知道了. map<string,string> mp; str ...

  9. Dom终

    l创建DOM元素 •createElement(标签名)  创建一个节点 •appendChild(节点)  追加一个节点 –例子:为ul插入li <!DOCTYPE html PUBLIC & ...

  10. Objective C 快速入门学习五

    <一>继承和多态 @class Complex 声明类(同C++) 子类函数成员 super 访问父类 同C++类似 .通过继承 在子类中添加新方法 .通过继承 在子类中添加新成员 .通过 ...