PAT乙级1052(C语言)-卖个萌 (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? @\/@

#include <stdio.h>  
#define MAX 5  
#define MAX_CH 10  
void read_expression(char array[][MAX], int* count);
int main(int argc, const char * argv[]) {
  char hand[MAX_CH][MAX], eye[MAX_CH][MAX], month[MAX_CH][MAX];
  int k, hand1, eye1, month1, eye2, hand2;
  int i, hand_count = 0, eye_count = 0, month_count = 0;
  read_expression(hand, &hand_count);
  read_expression(eye, &eye_count);
  read_expression(month, &month_count);
  scanf("%d", &k);
  for (i = 0; i < k; i++) {
    scanf("%d %d %d %d %d", &hand1, &eye1, &month1, &eye2, &hand2);
    if (hand1 <1 || hand1 > hand_count || hand2 < 1 || hand2 > hand_count) {
      printf("Are you kidding me? @\\/@\n");
      continue;
    }
    if (eye1 <1 || eye1 > eye_count || eye2 < 1 || eye2 > eye_count) {
      printf("Are you kidding me? @\\/@\n");
      continue;
    }
    if (month1 < 1 || month1 > month_count) {
      printf("Are you kidding me? @\\/@\n");
      continue;
    }
    printf("%s(%s%s%s)%s\n", hand[hand1 - 1], eye[eye1 - 1], month[month1 - 1], eye[eye2 - 1], hand[hand2 - 1]);
  }
  system("pause");
  return 0;
}
void read_expression(char array[][MAX], int* count) {
  int i, j, flag;
  char temp;
  i = 0;
  j = 0;
  flag = 0;
  while ((temp = getchar()) != '\n') {
    if (temp == '[' && !flag) {
      j = 0;
      flag = 1;
    }
    else if (temp == ']' && flag) {
      array[i][j] = '\0';
      i++;
      flag = 0;
    }
    else if (flag) {
      array[i][j++] = temp;
    }
  }
  *count = i;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值