ural 1993 This cheeseburger you don't need
2013-10-29 11:42
337 查看
顺次存到{} 【】 () 遇到逗号就处理下,最后处理逗号之后的
#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; }
相关文章推荐
- UVA 1993 This cheeseburger you don't need
- URAL 1993 This cheeseburger you don't need
- URAL 1993-This cheeseburger you don't need (模拟)
- This cheeseburger you don't need
- 多校联合训练赛 第三场D - This cheeseburger you don't need
- URAL1993-This cheeseburger you don't need
- Ural 1993 This cheeseburger you don't need
- ACM ICPC 2013-2014 D. This cheeseburger you don’t need(水~)
- mysqladmin: Can't turn off logging; error: 'Access denied; you need the SUPER privilege for this op
- mysqladmin: Can't turn off logging; error: 'Access denied; you need the SUPER privilege for this op
- you don't have permission to access / on this server(Apache Server权限访问问题)
- wampserver出现You don&#39;t have permission to access / on this server.
- .mysqladmin: Can't turn off logging; error: 'Access denied; you need the SUPER privilege for this op
- Note On <You Don't Know JS - Scope and Closures>
- 解决 The 'InnoDB' feature is disabled; you need MySQL built with 'InnoDB' to have it working
- 解决The 'InnoDB' feature is disabled; you need MySQL built with 'InnoDB' to have it working
- MySQL一次执行多条语句的实现及常见问题(C API Commands out of sync; you can't run this command now)
- PHP执行MYSQL存储过程报错:Commands out of sync; you can't run this command now 问题的解决
- error:2014 Commands out of sync; you can't run this command now
- Ural 1997-Those are not the droids you're looking for 二分图匹配