ural 1993 This cheeseburger you don't need
顺次存到{} 【】 () 遇到逗号就处理下,最后处理逗号之后的
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define inf 0x3f3f3f3f
typedef __int64 ll;
using namespace std; char ob[105],sub[105],veb[105],s[105];
int flag,i,l,o,sb,v,j,first; int main()
{
while(gets(s)!=NULL)
{
flag=0;
first=1;
i=o=sb=v=0;
l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]=='(')//sub
{
i++;
while(i<l&&s[i]!=')')
{
sub[sb++]=s[i++];
}
} else if(s[i]=='{')//ob
{
i++;
while(i<l&&s[i]!='}')
{
ob[o++]=s[i++];
}
}
else if(s[i]=='[')//verb
{
i++;
while(i<l&&s[i]!=']')
{
veb[v++]=s[i++];
}
}
else
{
if(s[i]==',')
{
for(j=0;j<o;j++)
{
if(first)
{
if(ob[0]>='a'&&ob[0]<='z')
{
putchar(ob[0]-32);
}
else putchar(ob[0]);
first=0;
continue;
}
putchar(ob[j]);
}
putchar(' ');
o=0;
for(j=0;j<sb;j++)
{
if(j==0&&sub[0]<='Z'&&sub[0]>='A')
putchar(sub[j]+32);
else putchar(sub[j]);
}
putchar(' ');
sb=0;
for(j=0;j<v;j++)
{
if(j==0&&veb[0]<='Z'&&veb[0]>='A')
putchar(veb[j]+32);
else putchar(veb[j]);
}
v=0;
//处理已经存了的 然后清零
putchar(',');
i++;
while(s[i]!='{'&&s[i]!='('&&s[i]!='[')
{
if(i<l){
putchar(s[i]);
i++;
}
else
{
flag=1;
break;
}
}
i--;
}
// if(flag) break;
}
}
if(o||sb||v)
{
for(j=0;j<o;j++)
{
if(first)
{
if(ob[0]>='a'&&ob[0]<='z')
{
putchar(ob[0]-32);
}
else putchar(ob[0]);
first=0;
continue;
}
putchar(ob[j]);
}
putchar(' ');
o=0;
for(j=0;j<sb;j++)
{
if(j==0&&sub[0]<='Z'&&sub[0]>='A')
putchar(sub[j]+32);
else putchar(sub[j]);
}
putchar(' ');
sb=0;
for(j=0;j<v;j++)
{
if(j==0&&veb[0]<='Z'&&veb[0]>='A')
putchar(veb[j]+32);
else putchar(veb[j]);
}
v=0;
}
putchar('\n');
}
return 0;
}
ural 1993 This cheeseburger you don't need的更多相关文章
- URAL 1993 This cheeseburger you don't need 模拟题
This cheeseburger you don't need 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1993 Descrip ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
- ural 2068. Game of Nuts
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...
- ural 2067. Friends and Berries
2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...
- ural 2066. Simple Expression
2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a v ...
随机推荐
- HDU-1584 蜘蛛牌(dfs)
可以多看看. 蜘蛛牌 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- Fitnesse+RestFixture:Web服务回归测试利器
RestFixture是Fitness的一个测试REST服务的插件,用于调用标准的http GET/POST等请求方法,并可以用XPath语法和Javascript语法检验http响应.本文介绍安装运 ...
- 微软Azure开始支持Docker技术
前一段时间还在与微软的技术人员讨论媒体转换服务的效率问题,如果应用 Docker将会有质的提高,没想到国外的Azure已经开始支持了,相信国内Azure支持也不远了.微软正在努力确保Azure成为开发 ...
- Ruby多字节字符的设计
Perl.Python的多字节字符处理方式是UCS(Universal Code Set),Ruby的多字节字符处理方式是CSI(Code Set Independent).UCS的做法是,不管你读取 ...
- mahout协同过滤算法
一直使用mahout的RowSimilarity来计算物品间的相似度,今晚仔细看了其实现,终于搞明白了他的计算逻辑. 上篇中介绍了整个itemBaseCF的mapreducer过程,主要有三个大的步骤 ...
- Multiple reportviewers on one page With reportviwer 11.0
Hi, evreryone: When I use VS 2012 to create report with reportviwer 11.0, I meet a problem abou ...
- SRM 511 DIV1 500pt(DP)
题目简述 给定n个数,两个人轮流取数,和之前两个人的取的数或起来,谁不能取数或者谁取到的数和之前的数或值为511谁输,问谁能够赢? 题解 刚开始的想法是直接搜,不过需要记录取过的值的状态,2^50显然 ...
- 设置mysql 在mac中的环境变量
在mac os的用户目录下有一个隐藏文件.bash_profile,编辑它就可以完成环境变量的创建. 比如要将mysql的运行目录加到环境变量中,可以在.bash_profile中新增如下一行: ex ...
- struts2+Hibernate4+spring3+EasyUI环境搭建之五:引入jquery easyui
1.下载jquery easyui组件 http://www.jeasyui.com/download/index.php 2.解压 放到工程中 如图 3.jsp引入组件:必须按照如下顺序 ...
- C#正则表达式判断字符串是否是金钱
public static bool IsMoney(string input) { string pattern = @"^\-{0,1}[0-9]{0,}\.{0,1}[0-9]{1,} ...