PAT乙级1052 卖个萌

37 篇文章 0 订阅

第二个测试点未过,有段错误

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int get1(string a,vector<string> &vec){
    string temp="";
    for(int i=0;i<a.length();i++){
        if(a[i]!='['&&a[i]!=']'&&a[i]!=' '){
            temp+=a[i];
        }
        if(a[i]==']'){
            vec.push_back(temp);
            temp="";
        }
    } 
    return 0;
}

int main(){
    int K,num,len1,len2,len3;
    string c,b,d;
    vector<string> hand1,hand2,eye,mouse,face;
    vector<vector<string> > cab;
    getline(cin,c);
    getline(cin,b);
    getline(cin,d);
    get1(c,hand1);
    get1(b,eye);
    get1(d,mouse);
    len1=hand1.size();
    len2=eye.size();
    len3=mouse.size();
    int len[5]={len1,len2,len3,len2,len1};
    cab.push_back(hand1);
    cab.push_back(eye);
    cab.push_back(mouse);
    cab.push_back(eye);
    cab.push_back(hand1);

    cin>>K;
    for(int i=0;i<K;i++){
        int flag=1;
        for(int j=0;j<5;j++){
            cin>>num;
            if(num>cab[j].size()){
                flag=0;
                break;
            }else{
                if(j==1){
                    face.push_back("(");
                }else if(j==4){
                    face.push_back(")");
                }
                face.push_back(cab[j][num-1]);
            }
        }
        if(flag==1){
            for(int j=0;j<face.size();j++){
                if(j==face.size()-1){
                    cout<<face[j]<<endl;
                }else{
                    cout<<face[j];
                }   
            }
        }else{
            cout<<"Are you kidding me? @\\/@"<<endl;
        }
        face.clear();
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值