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 ...
随机推荐
- mybatis 基础1(动态代理)
我目前使用的是mybatis 3.3.0版本. 可使用 1.xml文本, 2.dao类, 3.sqlSession.getMapper(Class<T> type), 生成sql类, 原理 ...
- git/gitLab
gitlab安装:http://www.360doc.com/content/15/0603/14/21631240_475362133.shtml http://www.cnblogs.com/wi ...
- HDOJ 4739 Zhuge Liang's Mines
Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- maven打包步骤_maven 构建项目
maven打包 1:先在pom文件中添加下面配置 jar <build> <plugins> <!-- compiler插件, 设定 ...
- boss设计参考的脑图
- mac 下 xampp 多域名 多站点 多虚拟主机 配置
前言:最近用mac工作了,需要搭建个调试前段程序的站点,选了xampp,需求是能同时运行多个站点,多个域名,目录自定义,网上找了好多资料,都感觉有些不符合心意,且复制文确实很多,甚至有些没实践过的在乱 ...
- PL/SQL创建数据表空间
创建数据表空间create tablespace stbss datafile 'E:\oracle\product\10.2.0\oradata\orcl\stbss_temp01.dbf' siz ...
- [Android分享] 【转帖】Android ListView的A-Z字母排序和过滤搜索功能
感谢eoe社区的分享 最近看关于Android实现ListView的功能问题,一直都是小伙伴们关心探讨的Android开发问题之一,今天看到有关ListView实现A-Z字母排序和过滤搜索功能 ...
- STL标准模板库介绍
1. STL介绍 标准模板库STL是当今每个从事C++编程的人需要掌握的技术,所有很有必要总结下 本文将介绍STL并探讨它的三个主要概念:容器.迭代器.算法. STL的最大特点就是: 数据结构和算法的 ...
- POJ 3641 快速幂+素数
http://poj.org/problem?id=3641 练手用,结果念题不清,以为是奇偶数WA了一发 #include<iostream> #include<cstdio> ...