P11784「FAOI-R4」问题跳转题解

· · 题解

P11784「FAOI-R4」问题跳转 题解

题目分析

本体答题思路就是输入一个题目,输出其洛谷网址

string e;cin>>e;
cout<<"https://www.luogu.com.cn/problem/"<<e<<endl;

但要注意的是:洛谷主题库里的题(P开头)可以省略P

if(e[0]>='0'&&e[0]<='9') cout<<"https://www.luogu.com.cn/problem/P"<<e<<endl;

AC代码

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        string e;cin>>e;
        if(e[0]>='0'&&e[0]<='9') cout<<"https://www.luogu.com.cn/problem/P"<<e<<endl;
        else cout<<"https://www.luogu.com.cn/problem/"<<e<<endl;
    }
}