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

#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. Winfrom 开发系统导航菜单

    先上图看效果在说. 效果图如上,在Web中这个一点难度都没有,几行Css+JS就搞定了.但是在Winfrom中.本来就是半杯水的水准,想做这个个导航菜单,发现真难找,找了很多都不合胃口,只能自己写个了 ...

  2. ch03-文字版面的设计

    Ch03: 文字版面的编辑 3.1 版面控制标记 3.1.1 取消文字换行: <NOBR> 1-取消换行文字实例:1-取消换行文字实例; 1-取消换行文字实例; 2-取消换行文字实例:2- ...

  3. mac下SSH很快被断开

    解决方法: 1. 切换到root账号:sudo bash -c 'su - root' 2. 修改/etc/ssh_config文件 ServerAliveCountMax 5 ServerAlive ...

  4. hdu 1026 Ignatius and the Princess I(优先队列+bfs+记录路径)

    以前写的题了,现在想整理一下,就挂出来了. 题意比较明确,给一张n*m的地图,从左上角(0, 0)走到右下角(n-1, m-1). 'X'为墙,'.'为路,数字为怪物.墙不能走,路花1s经过,怪物需要 ...

  5. MyGeneration 数据库驱动为空

    重做系统后安装了MyGeneration  但是安装完成后发现驱动中没有驱动信息,查了下网上的解决方案发下下面的可以完美解决,特作备忘: The problem is because of multi ...

  6. Delphi 使用串口模拟工具进行串口程序开发调试

      版权声明:本文为博主原创文章,如需转载请注明出处及作者. 本文由小李专栏原创,转载需注明出处:[http://blog.csdn.net/softwave/article/details/8907 ...

  7. linux常用命令之--文本编辑和文本内容查看命令

    linux的文本编辑和文本内容查看命令 1.文本编辑命令 vi:用于编辑文本文件,基本上可以分为三种模式,分别是一般模式.编辑模式.命令行模式. 一般模式:当编辑一个文件时,刚进入文件就是一般模式. ...

  8. Request、Request.Form和Request.QueryString的区别

    Request.Form:获取以POST方式提交的数据(接收Form提交来的数据): Request.QueryString:获取地址栏参数(以GET方式提交的数据) Request:包含以上两种方式 ...

  9. C++实现离散余弦变换(参数为Eigen矩阵)

    C++实现离散余弦变换(参数为Eigen矩阵) 问题描述 昨天写了一个参数为二维指针为参数的离散余弦变换,虽然改进了参数为二维数组时,当数组大小不确定时声明函数时带来的困难,但使用指针作为参数也存在一 ...

  10. linux中的livecd、liveDVD和其他安装方式简介

    下载了几种不同格式的centos版本的iso文件,从而对比下各种iso文件的差别,下载的内容如下: 下载之后,分别在虚拟机中进行安装,从而查看有何区别: 1. 使用LiveCD进行安装 在选择安装介质 ...