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

#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. rpm 命令参数使用详解

    RPM是RedHat Package Manager(RedHat软件包管理工具)类似Windows里面的“添加/删除程序” rpm 执行安装包 二进制包(Binary)以及源代码包(Source)两 ...

  2. POJ2976 Dropping tests 01分数规划

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

  3. IOS 支付宝 SDK 申请

    https://b.alipay.com/order/productDetail.htm?productId=2013080604609654&tabId=4#ps-tabinfo-hash

  4. http://blog.csdn.net/jbb0403/article/details/42102527

    http://blog.csdn.net/jbb0403/article/details/42102527

  5. Allegro从.brd文件中导出器件封装

    打开.brd文件,File→Export→Libraries,除了No libraries dependencies之外,所有选项都勾选上,设定好存放路径之后,Export. 注意事项: 1. 一般的 ...

  6. JavaScript中的事件冒泡机制

    事件冒泡机制 事件冒泡发生的条件:当为多个嵌套的元素设置了相同的事件处理程序,它们将触发事件冒泡机制.在事件冒泡中,最内部的元素将首先触发其事件,然后是栈内的下一个元素触发该事件,以此类推,直到到达最 ...

  7. 微信公众平台开发(57)Emoji表情符号

    微信公众平台开发 微信公众平台开发模式 企业微信公众平台 Emoji表情符号 作者:方倍工作室 地址:http://www.cnblogs.com/txw1958/p/crack-golden-egg ...

  8. 快速上手Android数据库操作

    Android采用关系型数据库SQLite3,它是一个支持SQL轻量级的嵌入式数据库,在嵌入式操作系统上有很广泛的应用,WM采用的也是SQLite3 关于过于.原理方面的东西在这篇文章里不会提到,但是 ...

  9. poj1000 A+B Problem

    Description Calculate a+b Input Two integer a,b (0<=a,b<=10) Output Output a+b Sample Input 1 ...

  10. 从零教你在Linux环境下(ubuntu)如何编译hadoop2.4

    问题导读: 1.如果获取hadoop src  maven包?2.编译hadoop需要装哪些软件?3.如何编译hadoop2.4?扩展:编译hadoop为何安装这些软件? 本文链接 http://ww ...