PAT乙级1052
来源:互联网 发布:许式伟 go语言编程 编辑:程序博客网 时间:2024/05/10 06:49
1052. 卖个萌 (20)
时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
萌萌哒表情符号通常由“手”、“眼”、“口”三个主要部分组成。简单起见,我们假设一个表情符号是按下列格式输出的:
[左手]([左眼][口][右眼])[右手]
现给出可选用的符号集合,请你按用户的要求输出表情。
输入格式:
输入首先在前三行顺序对应给出手、眼、口的可选符号集。每个符号括在一对方括号[]内。题目保证每个集合都至少有一个符号,并不超过10个符号;每个符号包含1到4个非空字符。
之后一行给出一个正整数K,为用户请求的个数。随后K行,每行给出一个用户的符号选择,顺序为左手、左眼、口、右眼、右手——这里只给出符号在相应集合中的序号(从1开始),数字间以空格分隔。
输出格式:
对每个用户请求,在一行中输出生成的表情。若用户选择的序号不存在,则输出“Are you kidding me? @\/@”。
输入样例:[╮][╭][o][~\][/~] [<][>] [╯][╰][^][-][=][>][<][@][⊙][Д][▽][_][ε][^] ...41 1 2 2 26 8 1 5 53 3 4 3 32 10 3 9 3输出样例:
╮(╯▽╰)╭<(@Д=)/~o(^ε^)oAre you kidding me? @\/@
/*#include<iostream>#include<vector>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<queue>#include<iomanip>using namespace std;int main(){string hand, eye, mouth;getline(cin, hand);getline(cin, eye);getline(cin, mouth);int K;int i = 0; intpos1 = 0, pos2 = 0;int c1, c2, c3;c1 = c2 = c3 = 0;int pos = 0;do {pos = hand.find('[', pos);if (pos >= 0){c1++; pos++;}elsebreak;} while (pos >= 0);pos = 0;do {pos = eye.find('[', pos);if (pos >= 0){c2++; pos++;}elsebreak;} while (pos >= 0);pos = 0;do {pos = mouth.find('[', pos);if (pos >= 0){c3++; pos++;}elsebreak;} while (pos >= 0);cin >> K;vector<int> v; int t;while (K--){for (int i = 0; i < 5; i++){cin >> t;v.push_back(t);}if (v[0] > c1 || v[1] > c2 || v[2] > c3 || v[3] > c2 || v[4] > c1){cout << "Are you kidding me? @\\/@" << endl;continue;}i = v[0];pos1 = 0, pos2 = 0;while (i--){pos1 = hand.find('[', pos1++);pos2 = hand.find(']', pos2++);}if (pos1 >= 0 && pos2 >= 0){pos2--;cout << hand.substr(pos1, pos2 - pos1) << "(";}i = v[1];pos1 = 0, pos2 = 0;while (i--){pos1 = eye.find('[', pos1++);pos2 = eye.find(']', pos2++);}if (pos1 >= 0 && pos2 >= 0){pos2--;cout << eye.substr(pos1, pos2 - pos1);}i = v[2];pos1 = 0, pos2 = 0;while (i--){pos1 = mouth.find('[', pos1++);pos2 = mouth.find(']', pos2++);}if (pos1 >= 0 && pos2 >= 0){pos2--;cout << mouth.substr(pos1, pos2 - pos1);}i = v[3];pos1 = 0, pos2 = 0;while (i--){pos1 = eye.find('[', pos1++);pos2 = eye.find(']', pos2++);}if (pos1 >= 0 && pos2 >= 0){pos2--;cout << eye.substr(pos1, pos2 - pos1) << ")";}i = v[4];pos1 = 0, pos2 = 0;while (i--){pos1 = hand.find('[', pos1++);pos2 = hand.find(']', pos2++);}if (pos1 >= 0 && pos2 >= 0){pos2--;cout << hand.substr(pos1, pos2 - pos1) << endl;}v.clear();}return 0;}*/#include<string>#include <iostream>#include <vector>using namespace std;int main() {vector<vector<string> > v;for (int i = 0; i < 3; i++) {string s;getline(cin, s);vector<string> row;int j = 0, k = 0;while (j < s.length()) {if (s[j] == '[') {while (k++ < s.length()) {if (s[k] == ']') {row.push_back(s.substr(j + 1, k - j - 1));break;}}}j++;}v.push_back(row);}int n;cin >> n;for (int i = 0; i < n; i++) {int a, b, c, d, e;cin >> a >> b >> c >> d >> e;if (a > v[0].size() || b > v[1].size() || c > v[2].size() || d > v[1].size() || e > v[0].size() || a < 1 || b < 1 || c < 1 || d < 1 || e < 1) {cout << "Are you kidding me? @\\/@" << endl;continue;}cout << v[0][a - 1] << "(" << v[1][b - 1] << v[2][c - 1] << v[1][d - 1] << ")" << v[0][e - 1] << endl;}return 0;}
不知道为啥我的(注释部分)过不了,样例一模一样,但一个点都过不了,很无奈,上述代码是看到别人比较好的代码
0 0
- PAT-乙级-1052
- PAT乙级1052
- PAT乙级1052 卖个萌
- PAT乙级 1004. 成绩排名
- PAT乙级 月饼 (25)
- PAT乙级 人口普查(20)
- PAT 乙级 1020.月饼
- PAT乙级1001
- PAT乙级1002
- PAT 乙级 1028.人口普查
- PAT乙级1003
- pat乙级总结
- PAT乙级1010-月饼
- PAT乙级题解
- PAT 乙级 1001
- PAT乙级 1001
- PAT 乙级1003
- PAT乙级--1003
- C语言实验——求绝对值(选择结构)
- OAuth 1.0的机制原理讲解及开发流程[QQ OAuth开发]
- spring boot mybatis
- Matlab画信号频谱图
- Nginx 记录请求分发日志
- PAT乙级1052
- Javascript中Json的深拷贝
- linux head和tail 查看文件
- 安卓开发中Application的作用
- 第一篇,博客
- Java 把字符串转换为字符串数组以及把字符串数组转化为字符串
- [51nod 1297]管理二叉树
- SQL中数据库事务的四大特性以及事务的隔离级别
- CodeVS2133星际竞速