# 官方题解|欢乐赛#44 T4
2025-04-09 22:09:04
发布于:浙江
4阅读
0回复
0点赞
T4
思路分析
首先本题需要要读入一个带空格的字符串,然后对于这个字符串进行遍历,依次循环替换成 A
到 Z
即可,可以利用 控制替换的字母,其中是你替换的次数。
代码
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
getline(cin, s);
char now = 'A';
int cnt = 0;
for(auto &it : s){
if(it == ' '){
it = (char)(now + cnt);
cnt = (cnt + 1) % 26;
}
}
cout << s;
}
这里空空如也
有帮助,赞一个