PAT乙级1052

本文介绍了一个使用C++编写的程序,该程序能够从输入中解析并生成各种表情符号,包括手部、眼睛和嘴巴的不同形态组合。通过读取标准输入获取手部、眼睛和嘴巴的样式列表,然后根据用户的指令生成具体的表情符号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <iostream>
#include <string>
#include <vector>
using namespace std;
void get(vector<string>& character){
	string input;
	int i,j;
	getline(cin,input);
	for(i=0,j=1;j<input.size();j++){
		if(input[i]!='[')
		{
			i++;continue;
		}
		if(input[j]==']' && character.size()<=10)
		{
			string temp=input.substr(i+1,j-i-1);
		//	cout<<temp<<endl;
			character.push_back(temp);
			i=j+1;
		}
	}
}
int main(int argc, char** argv) {
	int i,k,lh,le,m,rh,re;  //lh 左手 le 左眼睛 m 口 rh 右手
	string input;
	vector<string> hand,eye,mouth;
	get(hand);
	get(eye);
	get(mouth);
	cin>>k;
	for(i=0;i<k;i++)
	{
		cin>>lh>>le>>m>>re>>rh;
		if(lh-1>hand.size() || rh-1>hand.size() || le>eye.size() ||
		re>eye.size() || m>mouth.size())
		{
			cout<<"Are you kidding me? @\\/@"<<endl;
		}
		else
		{
			cout<<hand[lh-1]<<"("<<eye[le-1]<<mouth[m-1]<<eye[re-1]<<")"<<hand[rh-1]<<endl;
		}
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值