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 ...
随机推荐
- EF-在EF中运行sql语句
DbRawSqlQuery<int> result2 = db.Database.SqlQuery<int>("SELECT count(*) FROM test.s ...
- web 开发前端学习
调试插件:http://www.getpostman.com/ http://bootstrap.evget.com/javascript.html bootstrap: http://www.bo ...
- 关于外部引用JS,中文乱码的问题
asp.net 页面默认编码为UTF-8, 如果js嵌套写在asp.net中,不会导致中文乱码,因为他们具有相同的编码 外部引用js由于编码格式与asp.net的编码不同,javascript编码默认 ...
- hdu1026.Ignatius and the Princess I(bfs + 优先队列)
Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- Mac Pro 修改主机名
修改 主机名称 sudo scutil --set HostName jianbao-PC 修改 共享名称 sudo scutil --set ComputerName jianbao-PC
- style="visibility: hidden" 和 style=“display:none”区别
大多数人很容易将CSS属性display和visibility混淆,它们看似没有什么不同,其实它们的差别却是很大的. visibility属性用来确定元素是显示还是隐藏的,这用visibility=& ...
- qt-5.6.0 移植之纯净的linux文件系统的建立
为什么要建立一个最纯净的文件系统,一开始是想在qt-4.8.5的文件系统基础之上加东西,慎重想了一下,这方法行不通,以为有很多东西不熟悉.干脆就自己建立一个. 步骤很简单: 一:下载一个bulidro ...
- centos7 开机/etc/rc.local 不执行的问题
最近发现centos7 的/etc/rc.local不会开机执行,于是认真看了下/etc/rc.local文件内容的就发现了问题的原因了 #!/bin/bash # THIS FILE IS ADDE ...
- 转:bwa的使用方法
bwa的使用需要两中输入文件: Reference genome data(fasta格式 .fa, .fasta, .fna) Short reads data (fastaq格式 .f ...
- python——批量下载图片
前言 批量下载网页上的图片需要三个步骤: 获取网页的URL 获取网页上图片的URL 下载图片 例子 from html.parser import HTMLParser import urllib.r ...