返回题解分享
讨论 / 题解分享/ 帖子详情

字符串编号(编程题) - 题解

#include<bits/stdc++.h>
using namespace std;

int main(){
string s;
string str;
cin>>s;
int i=0;
while(i<s.size()){
if(i+2<=s.size()){
int n=stoi(s.substr(i,2));
if(n<=26){
char x='A'+n-1;
str+=x;
i+=2;
}
else{
int m=s[i]-'0';
char x='A'+m-1;
str+=x;
i++;
}
}
else{
int m=s[i]-'0';
char x='A'+m-1;
str+=x;
i++;
}
}
cout<<str;

return 0;
}
0 回复 0 转发 1 喜欢 1 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!