题解:P11784 「FAOI-R4」问题跳转
salt_ask_choose · · 题解
题目思路
这道题是一道很简单的模拟题,对于每一次提问,有2种情况
| 开头类型 | 输出结果 | 判断开头 | 处理输出 | 举例输入 | 举例输出 |
|---|---|---|---|---|---|
| 以数字开头 | 'https://www.luogu.com.cn/problem/' + 'P' + 数字 | 开头在'0'-'9'之间 | 先输出'https://www.luogu.com.cn/problem/' 然后输出'P'和 数字 | 3000 | https://www.luogu.com.cn/problem/P3000 |
| 以字母开头 | 'https://www.luogu.com.cn/problem/' + 输入 | 开头在'A'-'Z'之间 | 先输出'https://www.luogu.com.cn/problem/' 然后输出 输入 | P3000 | https://www.luogu.com.cn/problem/P3000 |
应该够详细了吧,上代码
代码
#include<bits/stdc++.h>
using namespace std;
int t;
string s;
int main(){
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
cin>>t;
for(int i=1;i<=t;i++){
cin>>s;
if(s[0]>='0'&&s[0]<='9') {//开头类型为数字
cout<<"https://www.luogu.com.cn/problem/"<<"P"<<s;
}
if(s[0]>='A'&&s[0]<='Z') {//开头类型为字母
cout<<"https://www.luogu.com.cn/problem/"<<s;
}
cout<<endl;
}
return 0;
}