PAT乙級 1052 賣個萌
阿新 • • 發佈:2018-11-28
萌萌噠表情符號通常由“手”、“眼”、“口”三個主要部分組成。簡單起見,我們假設一個表情符號是按下列格式輸出的:
[左手]([左眼][口][右眼])[右手]
現給出可選用的符號集合,請你按使用者的要求輸出表情。
輸入格式:
輸入首先在前三行順序對應給出手、眼、口的可選符號集。每個符號括在一對方括號 []內。題目保證每個集合都至少有一個符號,並不超過 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? @\/@
程式碼:
#include<stdio.h> int get_char(char a[][5]){ char ch; int i=0,j=0,sign=0; while((ch=getchar())!='\n'){ if(ch=='[') sign=1; if(sign&&ch!='['&&ch!=']') a[i][j++]=ch; if(ch==']') a[i++][j]='\0',j=0,sign=0; } return i; } int main(){ char Hands[10][5],Eyes[10][5],Mouth[10][5]; int cnt_h=get_char(Hands),cnt_e=get_char(Eyes),cnt_m=get_char(Mouth),K; scanf("%d",&K); int lh,le,m,re,rh; for(int i=0;i<K;++i){ scanf("%d%d%d%d%d",&lh,&le,&m,&re,&rh); if(lh>cnt_h||rh>cnt_h||le>cnt_e||re>cnt_e||m>cnt_m) printf("Are you kidding me? @\\/@"); else if(lh<1||rh<1||le<1||re<1||m<1) printf("Are you kidding me? @\\/@"); else printf("%s(%s%s%s)%s",Hands[lh-1],Eyes[le-1],Mouth[m-1],Eyes[re-1],Hands[rh-1]); if(i!=K-1) printf("\n"); } return 0; }