题目链接
代码中有注释;
// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#pragma warning(disable:4996);
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<stack>
#include<math.h>
using namespace std;
char hand[10][5], eye[10][5], mouth[10][5];
int getsymbol(char p[][5])
{//按字符读取表情
char c ;
int i = 0,j = 0;
while ((c = getchar()) != '\n') {//回车为结束符
if (c == '[') {//跳过对左右[]得吸收
while ((c = getchar()) != ']')//再次吸收字符
{
if (c == '\n') return (i-1);//按照题意不会出现这种情况
p[i][j] = c;
j++;
}
p[i][j] = '\0';//补上‘\0'使之成为字符串,格式合理;
i++;
j = 0;
}
}
return (i-1);//减一的原因是因为先给空间再用,所以最后一次给的空间没有用上,实际运用的就是i-1;
}
int main()
{
int h, e, m, n, i, a1, a2, a3, a4, a5;
h = getsymbol(hand);//分别拥有的个数,不能超过这个;
e = getsymbol(eye);
m = getsymbol(mouth);
scanf("%d", &n);
for (int i = 0;i < n;i++)
{
scanf("%d%d%d%d%d", &a1, &a2, &a3, &a4, &a5);
if (--a1 > h || --a5 > h || --a2 > e || --a4 > e||--a3 > m)//是不是超过所拥有的个数
puts("Are you kidding me? @\\/@");
else if (a1 < 0 || a2 < 0 || a3 < 0 || a4 < 0 || a5 < 0) puts("Are you kidding me? @\\/@");//所给参数不合理,为负数
else printf("%s(%s%s%s)%s\n", hand[a1], eye[a2], mouth[a3], eye[a4], hand[a5]);
}
return 0;
}