顺次存到{} 【】 () 遇到逗号就处理下,最后处理逗号之后的

#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的更多相关文章

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

  2. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  3. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  4. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  5. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  6. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

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

  8. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

  9. ural 2066. Simple Expression

    2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a v ...

随机推荐

  1. XTUOJ1247 Pair-Pair 预处理+暴力

    分析:开个1000*1000的数组,预处理矩阵和,然后分类讨论就好 时间复杂度:O(n) #include <cstdio> #include <iostream> #incl ...

  2. 《Python 学习手册4th》 第八章 列表与字典

    ''' 时间: 9月5日 - 9月30日 要求: 1. 书本内容总结归纳,整理在博客园笔记上传 2. 完成所有课后习题 注:“#” 后加的是备注内容 (每天看42页内容,可以保证月底看完此书) “重点 ...

  3. [Web API] 如何让 Web API 统一回传格式以及例外处理[转]

    [Web API] 如何让 Web API 统一回传格式以及例外处理 前言 当我们在开发 Web API 时,一般的情况下每个 API 回传的数据型态或格式都不尽相同,如果你的项目从头到尾都是由你一个 ...

  4. 通过SQL进行远程访问

    通过SQL语句访问远程数据库 1.得建立链接服务器:  --删除链接服务器 if exists(select * from master.dbo.sysservers where isremote=0 ...

  5. Javascript——说说js的调试

    最近比较吐槽,大家都知道,现在web前端相对几年前来说已经变得很重了,各种js框架,各种面对对象,而且项目多了,就会提取公共模块. 这些模块的UI展示都一样,不一样的就是后台逻辑,举个例子吧,我们做企 ...

  6. 《Genesis-3D开源游戏引擎--横版格斗游戏制作教程:简介及目录》(附上完整工程文件)

    介绍:讲述如何使用Genesis-3D来制作一个横版格斗游戏,涉及如何制作连招系统,如何使用包围盒实现碰撞检测,软键盘的制作,场景切换,技能读表,简单怪物AI等等,并为您提供这个框架的全套资源,源码以 ...

  7. 【Spark学习】Apache Spark for 第三方Hadoop分发版

    Spark版本:1.1.1 本文系从官方文档翻译而来,转载请尊重译者的工作,注明以下链接: http://www.cnblogs.com/zhangningbo/p/4137979.html

  8. Android JNI之C/C++层调用JAVA

    转载请声明:原文转自:http://www.cnblogs.com/xiezie/p/5930032.html 从C/C++层调用JAVA层代码步骤: 1. 在JAVA类中创建java方法和本地方法 ...

  9. RHEL6.4 KVM 桥接上网的设置

    关闭网络管理器 chkconfig NetworkManager off  ##和桥接有冲突,要关闭 service NetworkManager stop   修改eth0为物理网口,br0为桥接网 ...

  10. HDU 5744 Keep On Movin (贪心)

    Keep On Movin 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5744 Description Professor Zhang has k ...