PAT (Basic Level) Practice (中文)- 1052 卖个萌(20 分)

简介: PAT (Basic Level) Practice (中文)- 1052 卖个萌(20 分)

题目链接:点击打开链接

题目大意:略。

解题思路:


  • 注意当中有越界的下标。
  • 注意 “\\” 转义字符。
  • 题目有些字符输出不了,没事,其他正常即可。

AC 代码

#include<bits/stdc++.h>
#include<cmath>
#define mem(a,b) memset(a,b,sizeof a);
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
vector<string> v[5],tv;
string ts;
int main()
{
    int n=3;
    string s;
    char c;
    for(int i=0;i<n;i++)
    {
        getline(cin,s);
        int len=s.length();
        for(int i=0,f=0;i<len;i++)
        {
            c=s[i];
            if(c==']')
            {
                f=0;
                tv.push_back(ts);
                ts.clear();
            }
            if(f) ts.append(1,c);
            if(c=='[') f=1;
        }
        v[i]=v[n-i+1]=tv;
        tv.clear();
    }
//    for(int i=0;i<5;i++)
//    {
//        for(int j=0;j<v[i].size();j++)
//        {
//            printf("%s ",v[i][j].c_str());
//        }
//        puts("");
//    }
    scanf("%d",&n);
    int a;
    while(n--)
    {
        int f=1; ts.clear();
        for(int i=0;i<5;i++)
        {
            scanf("%d",&a);
            if(!f) continue;
            if(a>v[i].size() || a<=0){f=0; continue;}
            if(i==1) ts.append(1,'(');
            ts.append(v[i][a-1]);
            if(i==3) ts.append(1,')');
        }
        if(!f) puts("Are you kidding me? @\\/@");
        else printf("%s\n",ts.c_str());
    }
    return 0;
}
目录
相关文章
|
10月前
|
C语言 C++
PAT (Basic Level) Practice (中文)1099 性感素数(20分)
“性感素数”是指形如 (p, p+6) 这样的一对素数。之所以叫这个名字,是因为拉丁语管“六”叫“sex”(即英语的“性感”)。(原文摘自 http://mathworld.wolfram.com/SexyPrimes.html) 现给定一个整数,请你判断其是否为一个性感素数。
85 0
PAT (Basic Level) Practice (中文) 1036 跟奥巴马一起编程 (15 分) p89
PAT (Basic Level) Practice (中文) 1036 跟奥巴马一起编程 (15 分) p89
125 0
|
算法
PAT (Basic Level) Practice (中文)1028. 人口普查(20分)
PAT (Basic Level) Practice (中文)1028. 人口普查(20分)
76 0
|
存储 测试技术
PAT (Basic Level) Practice (中文) 1004 成绩排名 (20 分)
PAT (Basic Level) Practice (中文) 1004 成绩排名 (20 分)
63 0
PAT (Basic Level) Practice (中文) B1046 划拳 (15 分)
PAT (Basic Level) Practice (中文) B1046 划拳 (15 分)
59 0
PAT (Basic Level) Practice (中文) 1016 部分A+B (15 分)
PAT (Basic Level) Practice (中文) 1016 部分A+B (15 分)
64 0
|
测试技术
PAT (Basic Level) Practice (中文) B1011 A+B 和 C (15 分)
PAT (Basic Level) Practice (中文) B1011 A+B 和 C (15 分)
76 0
PAT (Basic Level) Practice (中文) B1011 A+B 和 C (15 分)
|
C语言
PAT (Basic Level) Practice (中文) B1026 程序运行时间 (15 分)
PAT (Basic Level) Practice (中文) B1026 程序运行时间 (15 分)
96 0
|
存储
PAT (Basic Level) Practice (中文) 1041 考试座位号 (15 分)
PAT (Basic Level) Practice (中文) 1041 考试座位号 (15 分)
64 0
PAT (Basic Level) Practice (中文) 1041 考试座位号 (15 分)
PAT (Basic Level) Practice (中文)- 1028 人口普查(20 分)
PAT (Basic Level) Practice (中文)- 1028 人口普查(20 分)
93 0