PAT乙级1052. 卖个萌(C语言)

AC

PAT乙级真题题解目录


/**
 * 1. 读取符号
 *		- getchar() != '\n';
 * 		- 正则表达式 "%[^]]" 读取符号;
 * 		- 统计符号集的长度;
 * 2. 颜文字 实际大小可能不止一个字符
 * 3. 颜文字在命令行窗口存在无法显示的情况,需要提交答案才能真正判断正确性;
 */
#include <stdio.h>

int get(char arr[][5]){
	int i = 0;//存储符号的下标
	char c; 
	while ((c = getchar()) != '\n') {
		if (c == '[') {
			scanf("%[^]]", arr[i++]);//读入 ']' 之前的字符 
		}
	}
	return i;
}
int main(){
	char hand[10][5], eye[10][5], mouth[10][5];
	int cnt_hand = get(hand);
	int cnt_eye = get(eye);
	int cnt_mouth = get(mouth);
	int K;//用户请求的个数
	scanf("%d", &K);
	while (K-- > 0) {
		int lhand, leye, m, reye, rhand;
		scanf("%d %d %d %d %d", &lhand, &leye, &m, &reye, &rhand);
		if (lhand > cnt_hand || lhand < 1 || leye > cnt_eye 
			|| leye < 1 || m > cnt_mouth || m < 1 || reye > cnt_eye || reye < 1 
			|| rhand > cnt_hand || rhand < 1 ) {
			printf("Are you kidding me? @\\/@\n");
		} else {
			printf("%s(%s%s%s)%s\n", hand[lhand-1], eye[leye-1], mouth[m-1], eye[reye-1], hand[rhand-1]);
		}
	} 
	return 0;
}
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值