1. 程式人生 > >1052 賣個萌 (20 分)//部分正確

1052 賣個萌 (20 分)//部分正確

 

 

1052 賣個萌 (20 分)

萌萌噠表情符號通常由“手”、“眼”、“口”三個主要部分組成。簡單起見,我們假設一個表情符號是按下列格式輸出的:

[左手]([左眼][口][右眼])[右手]

現給出可選用的符號集合,請你按使用者的要求輸出表情。

輸入格式:

輸入首先在前三行順序對應給出手、眼、口的可選符號集。每個符號括在一對方括號 []內。題目保證每個集合都至少有一個符號,並不超過 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? @\/@

 部分正確(12分)

#include<iostream>
#include<string>
using namespace std;
void getpic(string t, string hands[], int &n_hands);
int main()
{
	string hands[11];
	int n_hands = 0;
	string eyes[11];
	int n_eyes = 0;
	string mouths[11];
	int n_mouths = 0;
	string t;
	getline(cin, t);
	getpic(t, hands, n_hands);
	getline(cin, t);
	getpic(t, eyes, n_eyes);
	getline(cin, t);
	getpic(t, mouths, n_mouths);
	int n;
	cin >> n;
	int hands1[10000];
	int hands2[10000];
	int eyes1[10000];
	int eyes2[10000];
	int mouth1s[10000];
	for (int i = 0; i < n; i++) {
		cin >> hands1[i] >> eyes1[i] >> mouth1s[i] >> eyes2[i] >> hands2[i];
	}
	for (int i = 0; i < n; i++) {
		int h1=hands1[i], e1=eyes1[i],m= mouth1s[i],
			e2=eyes2[i], h2= hands2[i];

		if (h1 > n_hands || e1 > n_eyes || m > n_mouths || e2 > n_eyes || h2 > n_hands)
			cout << "Are you kidding me? @\\/@";
		else {
			cout << hands[h1]<<'(' << eyes[e1] << mouths[m] << eyes[e2] << ')' << hands[h2] << endl;
		}
	}
	return 0;
}
void getpic(string t,string hands[],int &n_hands) {
	int left = 0, right = 0;
	for (int i = 0; i < t.length(); i++) {
		if (t[i] == '[')
			left = i;
		if (t[i] == ']') {
			right = i;
			hands[++n_hands] =  t.substr(left+1, right-left-1);
		}
	}
}