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

#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. 关于DatePicker控件在IsEnabled为False视觉效果没有明显辨识度的处理方法

    DatePicker控件在IsEnabled为False时界面没有让人看上去不可用(背景为灰色等)的效果.容易让用户迷惑. 可以用下面的代码增加设置透明度的触发器来解决(XAML以及C#方式): &l ...

  2. oracle返回多结果集

    kavy 原文 oracle返回多结果集 Oracle存储过程: create or replace procedure P_Sel_TopCount2(in_top in number, out_c ...

  3. XTUOJ 1252 Defense Tower 贪心

    题目链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1252 思路:考虑每条边对玩家的伤害 假设连接的节点是u,v,破坏 ...

  4. POJ2976 Dropping tests 01分数规划

    裸题 看分析请戳这里:http://blog.csdn.net/hhaile/article/details/8883652 #include<stdio.h> #include<a ...

  5. hashtable,hashMap,vector和ArrayList

    关于vector,ArrayList,hashMap和hashtable之间的区别 vector和ArrayList:  线程方面:  vector是旧的,是线程安全的  ArrayList是java ...

  6. UNDO表空间设置

    flashback query和flashback table都是以用UNDO表空间的内容来进行恢复数据 查看undo内容保存的时间: SQL> show parameter undo_re N ...

  7. librtmp推流使用aac编码音频的html5和flash播放问题

    公司项目中使用rtmp推流,音频编码aac.视频编码H264.windows和android平台都没有发现问题.然而在IOS版本的APP中发现几个问题:1. 推流后flash播放异常2. IOS平台微 ...

  8. Java并发控制机制详解

    在一般性开发中,笔者经常看到很多同学在对待java并发开发模型中只会使用一些基础的方法.比如Volatile,synchronized.像Lock和atomic这类高级并发包很多人并不经常使用.我想大 ...

  9. 关于P2P架构的网络游戏

    以下内容摘自<ActionScript大型网页游戏开发> ————————————————————————————————————————————————————————— P2P架构 P ...

  10. ocp 1Z0-047 1-60题解析

    1. You need to load information about new customers from the NEW_CUST table into the tables CUST and ...