This cheeseburger you don't need

题目连接:

http://acm.timus.ru/problem.aspx?space=1&num=1993

Description

Master Yoda is the oldest member of the Jedi Council. He conducts preparatory classes of little Younglings up to the moment they get a mentor. All Younglings adore master Yoda and they hope to grow as strong and wise as he is. Just like all little children, Younglings are absolutely hooked on new games and ideas. Now they decided to learn to speak just like master Yoda. Help the Younglings understand how Yoda would say this or that sentence.
Yoda is speaking the Galactic language using the specific word order — so-called "object-subject-verb".
Your program receives a sentence that interests the Younglings. They have already highlighted all important parts in the sentence. They use the curly {}-brackets for objects, round ()-brackets for subjects and square []-brackets for verbs.
A sentence in the input can be simple or complex. If the sentence is complex, then it consists of two simple sentences separated by a comma. Sometimes a comma is followed by a conjunction that is not in the brackets.
Each simple question has exactly one object, one subject and one verb. Your task is to simply put them in the correct order. Namely, first the object, then the subject, finally the verb. Also, please do not forget that only the first word in the whole sentence should begin with capital letter.

Input

The single line contains a sentence that interests the Younglings. The length of the sentence does not exceed 100 characters. All the words in the sentence consist of Latin letters. The first letter of the first word is capitalized and the rest are small. The sentence may contain a comma. Each simple sentence contains all three types of brackets. Each pair of brackets surrounds one or more words. No pair of brackets can surround the other bracket. Brackets are always located on the borders of words. The words in the sentence are separated by a single space. There is no space character before a comma or a closing bracket and also after an opening bracket. The conjunction (which can be only after a comma) is the only word that is not surrounded by a pair of brackets.

Output

Print the sentence with the word order Yoda would use. All brackets must be omitted. You should separate the words by a single space.

Sample Input

(We) [are] {blind}, if (we) [could not see] {creation of this clone army}

Sample Output

Blind we are, if creation of this clone army we could not see

Hint

题意

没括号的原样输出,有括号的就优先输出大括号,中括号,然后小括号这样

句首需要大写

题解:

模拟题,烦……

代码

#include <bits/stdc++.h>using namespace std;string base;
vector < string > str;string Clear_32(string s){string res;int Ed = s.size() - 1;for( ; Ed >= 0 && s[Ed] == ' ' ; -- Ed);for(int i = 0 ; i < s.size() ; ++ i){if( s[i] != ' '){for(int j = i ; j <= Ed ; ++ j) res.push_back( s[j] );break;}}return res;
}void Solve( string s , int INDEX ){stack < int > sp;string F[4];int pos[4];F[0]=F[1]=F[2]=F[3]="";bool find = false;for(int i = 0 ; i < s.size() ; ++ i){if(s[i] == '[' || s[i] == '(' || s[i] == '{'){sp.push( i );if( find == false ) F[0]=s.substr(0,i);find = true;if(s[i] == '{') pos[1] = i;else if(s[i] =='(') pos[2] = i;else pos[3] = i;}else if(s[i] == ']' || s[i] == ')' || s[i] == '}'){string * ptr = F;int extra = 0;if( s[i] == '}' ) extra = 1;else if( s[i] == ')' ) extra=2;else extra=3;ptr += extra;*ptr=s.substr(pos[extra]+1,i-pos[extra]-1);} }for(int i = 1 ; i < 4 ; ++ i) F[i] = Clear_32( F[i] );cout << F[0];if(INDEX==0){for(int i = 0 ; i < 4 ; ++ i)if(F[i].size()){if(F[i][0] <= 'z' && F[i][0] >='a'){F[i][0] = F[i][0] - 'a' + 'A';}for(int j = 1 ; j < F[i].size() ; ++ j){if(F[i][j] <= 'Z' && F[i][j] >= 'A'){F[i][j] = F[i][j] - 'A' + 'a';}}for(int k = i + 1 ; k < 4 ; ++ k){for(int v = 0 ; v < F[k].size() ; ++ v){if(F[k][v] <= 'Z' && F[k][v] >= 'A'){F[k][v] = F[k][v] - 'A' + 'a';}}}break;}}int isfirst = 0;for(int i = 1 ; i < 4 ; ++ i){if(F[i].size()){if(isfirst==0) isfirst = 1;else cout << " ";cout << F[i];}}
}int main(int argc,char *argv[]){
//  freopen("out.txt" , "w" , stdout );getline(cin , base);for(int i = 0 ; i < base.size() ; ++ i){int j;string temp;for(j = i ; j < base.size() ; ++ j){if( base[j] ==',' && i != j ) break;temp.push_back( base[j] );}str.push_back( temp );i = j - 1;}for(int i = 0 ; i < str.size() ; ++ i) Solve( str[i] , i );cout << endl;return 0;
}

URAL 1993 This cheeseburger you don't need 模拟题相关推荐

  1. URAL 1993 This cheeseburger you don't need

    其实就是一个指定字符串的交换位置...还挺恶心的..写了很长不容易就贴一下吧... 各种拆分字符串,合并字符串...还有处理大小写...应该没什么trick /******************** ...

  2. ural 2032 Conspiracy Theory and Rebranding (数学水题)

    ural 2032  Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...

  3. ACM 网址和一些建议

    USACO http://ace.delos.com/usacogate 美国著名在线题库,专门为信息学竞赛选手准备 TJU http://acm.tongji.edu.cn/ 同济大学在线题库,唯一 ...

  4. ACRush 楼天城回忆录

    利用假期空闲之时,将这几年 GCJ , ACM , TopCoder 参加的一些重要比赛作个回顾.首先是 GCJ2006 的回忆. Google Code Jam 2006 一波三折: Google ...

  5. [存档]xx-09210xxx-2010-ACM-ICPC竞赛总结

    存档作对比.发现完全没进步啊,真惭愧. ==== ACM-ICPC亚洲区预选赛 分区赛竞赛个人总结 2010年赛季 一.个人训练情况 1.训练的数量与质量情况 做题总数: 231=128(BuptOJ ...

  6. ACM大量习题题库及建议培养计划

    ACM大量习题题库 ACM大量习题题库  现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO h ...

  7. ACM题目和培养训练!!!

    ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...

  8. 』 [大话IT]我编的计算机基础教材,大家批判批判

    :十点半开始 提交日期:2006-10-5 11:00:00   我们教研室主要负责计算机基础教学.去年因为评职称的需要,大家商量决定合作编一本教材.当然,评职称只是动因,根据教学需要规划内容,遍 ...

  9. 【转】楼天城楼教主的acm心路历程(作为励志用)

    [转]楼天城楼教主的acm心路历程(作为励志用) 利用假期空闲之时,将这几年GCJ,ACM,TopCoder 参加的一些重要比赛作个 回顾.昨天是GCJ2006 的回忆,今天时间上更早一些吧,我现在还 ...

最新文章

  1. CSS类选择器选择多个类用逗号隔开
  2. nginx二进制编译-启动脚本编写
  3. (转)STORM启动与部署TOPOLOGY
  4. 素数的线性筛法java,埃氏筛 线性筛(欧拉筛) 算法解析
  5. github API 实例 python源码 爬取用户信息
  6. acr122 java,ACR122开发包 SDK v1.1 [CDR 146]
  7. 查看服务器阵列卡型号6,怎么查看 dell 阵列卡型号#如何通过服务器自检画面的信息查看当前阵列卡的型号...
  8. 1、高动态范围成像介绍
  9. 2022-2027年中国发动机行业市场调研及未来发展趋势预测报告
  10. pytohn用Pillow或OpenCV删除图片某种颜色
  11. sfm算法之三角化(三角测量)
  12. 5.11 Go语言文本大数据处理(2):文件分割与入库
  13. HPC走出全新路线:《开放架构HPC技术与生态白皮书》注解
  14. java web 登录_javaWeb实现登录功能
  15. 【很逗,很经典】【与靠谱IT男的浪漫闪婚记】——转个很可爱的帖子,貌似男女猪脚是咱IT人士呢...
  16. 【报告分享】从人群、场景出发洞察母婴消费新机遇-魔镜市场情报(附下载)
  17. Cross compiling Windows binaries from Linux
  18. #pragma加载lib文件
  19. 使用Element的 InfiniteScroll 无限滚动组件报错
  20. 我为OpenHarmony 写代码,战“码”先锋第二期正式开启!

热门文章

  1. go gdb调试 参数设置 减小执行文件体积
  2. Compass 编译.scss文件的问题
  3. 多元函数的二阶导数对应的矩阵
  4. PHP将死。何以为继?
  5. FAT32转换NTFS格式的命令
  6. linux大文件拷贝,Linux如何提高大文件的拷贝效率
  7. 继承redis spring_实例讲解Springboot以Repository方式整合Redis
  8. android handler的机制和原理_一文搞懂handler:彻底明白Android消息机制的原理及源码
  9. python 循环中报错 继续运行_python中列表删除和多重循环退出
  10. 2021年度脑机接口重大事件和进展汇总