1032.ZOJ
来源:互联网 发布:java聊天源代码 编辑:程序博客网 时间:2024/06/15 12:50
题目描述:
读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出。
输入:
题目包含多组用例,每组用例占一行,包含ZOJ三个字符,当输入“E”时表示输入结束。
1<=length<=100。
输出:
对于每组输入,请输出一行,表示按照要求处理后的字符串。
具体可见样例。
样例输入:
ZZOOOJJJ
ZZZZOOOOOJJJ
ZOOOJJ
E
样例输出:
ZOJZOJOJ
ZOJZOJZOJZOO
读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出。
输入:
题目包含多组用例,每组用例占一行,包含ZOJ三个字符,当输入“E”时表示输入结束。
1<=length<=100。
输出:
对于每组输入,请输出一行,表示按照要求处理后的字符串。
具体可见样例。
样例输入:
ZZOOOJJJ
ZZZZOOOOOJJJ
ZOOOJJ
E
样例输出:
ZOJZOJOJ
ZOJZOJZOJZOO
ZOJOJO
#include <iostream>#include <string>#include <algorithm>using namespace std;int main(){ string str; while(cin >> str) { if(str == "E") break; int count1 = count(str.begin(),str.end(),'Z'); int count2 = count(str.begin(),str.end(),'O'); int count3 = count(str.begin(),str.end(),'J'); int total_count = count1 + count2 + count3; for(int i = 0; i < total_count; ++i) { if(count1-- > 0) { cout << 'Z'; } if(count2-- > 0) { cout << 'O'; } if(count3-- > 0) { cout << 'J'; } } cout << endl; } return 0;}
0 0
- 1032.ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- TOJ 1588 Cornfields -- 二维RMQ
- 提交时提示错误This Bundle is invalid.New apps and app updates submitted to the App Store must be built wit
- 《程序员编程艺术》笔记—左旋转字符串
- [Cocos2d-x v3.x]Mac OX 创建新的Cocos2d-x 3.0 项目
- nbmvbxcjhfvesfteiotigfpoweughsdhfjashfjkajkfjklsdg
- 1032.ZOJ
- 湖南省第九届大学生程序设计竞赛
- 【线性表】链式存储结构之:双链表
- 复数运算
- Ubuntu下用arm-none-linux-gnueabi交叉编译libxml2
- OCP 1Z0 051 45
- 面向对象的3个基本要素和5个基本设计原则(整理)
- 2014百度之星资格赛第四题
- 关于C#调用VC编的DLL后报“System.AccessViolationException:尝试读取或写入受保护的内存