1052. 卖个萌 (20)

来源:互联网 发布:c 五子棋源码 编辑:程序博客网 时间:2024/05/18 14:46

萌萌哒表情符号通常由“手”、“眼”、“口”三个主要部分组成。简单起见,我们假设一个表情符号是按下列格式输出的:

左手[右手]
现给出可选用的符号集合,请你按用户的要求输出表情。

输入格式:

输入首先在前三行顺序对应给出手、眼、口的可选符号集。每个符号括在一对方括号[]内。题目保证每个集合都至少有一个符号,并不超过10个符号;每个符号包含1到4个非空字符。

之后一行给出一个正整数K,为用户请求的个数。随后K行,每行给出一个用户的符号选择,顺序为左手、左眼、口、右眼、右手——这里只给出符号在相应集合中的序号(从1开始),数字间以空格分隔。

输出格式:

对每个用户请求,在一行中输出生成的表情。若用户选择的序号不存在,则输出“Are you kidding me? @\/@”。

输入样例:
[╮][╭][o][~][/~] [<][>]
[╯][╰][^][-][=][>][<][@][⊙]
[Д][▽][_][ε][^] …
4
1 1 2 2 2
6 8 1 5 5
3 3 4 3 3
2 10 3 9 3
输出样例:
╮(╯▽╰)╭
<(@Д=)/~
o(^ε^)o
Are you kidding me? @\/@

注意两点:
1.要用getline函数输入字符串,因为字符串中可能有空格
2.‘\’要用两个‘\’才能打印出来,差点忘了。

#include<iostream>#include<string.h>#include<string>#include<stdlib.h>using namespace std;int main(){    string hands[3][11] = { "" };    int k, num[3] = { 0 };    for (int i = 0; i < 3; i++) {        string s1 = "";        getline(cin, s1);        k = 1;        for (int j = 0; j < s1.size(); j++) {            if (s1[j] == '[') {                j++;                while (s1[j] != ']') {                    hands[i][k].append(1, s1[j]);                    j++;                }                k++;            }        }        num[i] = k;    }    int K = 0, a[5];    cin >> K;    for (int i = 0; i < K; i++) {        bool flag = true;        for (int j = 0; j < 5; j++) {            cin >> a[j];            if (a[j] <= 0)                flag = false;            if (j == 0 || j == 4)                if (a[j] >= num[0])                    flag = false;            if (j == 1 || j == 3)                if (a[j] >= num[1])                    flag = false;            if (j == 2)                if (a[j] >= num[2])                    flag = false;        }        if (flag) {            for (int j = 0; j < 5; j++) {                if (j == 0 || j == 4) {                    if (j == 0)                        cout << hands[0][a[j]] << "(";                    else cout << hands[0][a[j]];                }                else if (j == 1 || j == 3) {                    if (j == 3)                        cout << hands[1][a[j]] << ")";                    else cout << hands[1][a[j]];                }                else if (j == 2)                    cout << hands[2][a[j]];            }        }        else {            cout << "Are you kidding me? @\\/@";        }        cout << endl;    }    return 0;}
0 0
原创粉丝点击