萌萌噠表情符號通常由“手”、“眼”、“口”三個主要部分組成。簡單起見,我們假設一個表情符號是按下列格式輸出的:
[左手]([左眼][口][右眼])[右手]
現給出可選用的符號集合,請你按用戶的要求輸出表情。
輸入格式:
輸入首先在前三行順序對應給出手、眼、口的可選符號集。每個符號括在一對方括號[]內。題目保證每個集合都至少有一個符號,並不超過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? @\/@
=========================================================================================
思路:
使用字符串數組,然後整行讀入後老老實實地用“[”和“]”作標識符拆分。
特別注意輸入的K小於等於0的情況也要考慮。
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
int main()
{
string hand[15];
string eyes[15];
string mouth[15];
string moe,t;
int n,i,j,h=0,e=0,m=0,len,temp;
bool flag;
for(i=0;i<3;i++)
{
t.clear();
getline(cin,t);
len = t.size();
for(j=0;j<len;j++)
{
if(t[j] == '[')
{
while(t[j+1]!=']' && j+1<len)
{
if(i == 0)
hand[h] += t[j+1];
else if(i == 1)
eyes[e] += t[j+1];
else
mouth[m] += t[j+1];
j++;
}
if(i == 0)
h++;
else if(i == 1)
e++;
else
m++;
j--;
}
}
}
cin>>n;
while(n--)
{
moe.clear();
flag = true;
for(i=0;i<5;i++)
{
cin>>temp;
temp--;
if(temp < 0)
flag = false;
if(i==0 || i==4)
{
if(temp >= h)
flag = false;
}
else if(i==1 || i==3)
{
if(temp >= e)
flag = false;
}
else
if(temp >= m)
flag = false;
if(flag == true)
{
if(i==0 || i==4)
moe += hand[temp];
else if(i==1 || i==3)
moe += eyes[temp];
else
moe += mouth[temp];
if(i == 0)
moe += '(';
else if(i == 3)
moe += ')';
}
}
if(flag == true)
cout<<moe<<endl;
else
cout<<"Are you kidding me? @\\/@"<<endl;
}
return 0;
}