yuri01 题解分享 · 2024/12/26
字符串编号(编程题) - 题解
```cpp // A -> 1 Z -> 26 #include <bits/stdc++.h> using namespace std; string ss = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main() { string str; cin >> str; for (int i = 0; i < str.size();) { string s2 = str.substr(i, 2); string s1 = str.substr(i, 1); if (s2 <= "26") { int x = stoi(s2); cout << ss[x]; i += 2; } else { int x = stoi(s1); cout << ss[x]; i++; } } return 0; } ```
查看全文
2 0 0 5
DB小左 题解分享 · 2025/3/11
字符串编号(编程题) - 题解
``` #include<bits/stdc++.h> using namespace std; int cut_num(string& str) { int l = 2; string s = str.substr(0, 2); if(stoi(s)>26){ l = 1; s = str.substr(0, 1); } str.erase(0,l); return stoi(s); } char inttochar(int num){ return 'A' + num - 1; } int main(){ string str; cin>>str; while(str != "") { int num = cut_num(str); cout<<inttochar(num); } } ```
查看全文
1 0 0 13
薛时锦 题解分享 · 2024/4/7
字符串编号(编程题) - 题解
``` #include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int len = s.size(); string str; int i = 0; while(i < len){ if (stoi(s.substr(i,2)) <= 26) { str += (char)(stoi(s.substr(i,2)) + 64); i += 2; }else{ str += (char)(stoi(s.substr(i,1)) + 64); i ++; } } cout << str; return 0; } ```
查看全文
1 0 4 9
seabra 题解分享 · 2024/4/9
字符串编号(编程题) - 题解
include 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; }
查看全文
2 0 1 14
NorthChern 题解分享 · 2024/4/6
字符串编号(编程题) - 题解
``` import java.util.Scanner; public class Main { //1.每次两个数字两个数字地选取 //2.如果当前数字大于26,就选取上一个数字 static char[] table = {0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); char[] c = scanner.next().toCharArray(); StringBuilder res = new StringBuilder(); //使用StringBuilder进行优化 int n = c.length; for (int i = 0; i < n; i++) { if(i + 1 == n){ res.append(table[c[i] - '0']); break; } int big = c[i] - '0'; int small = c[i + 1] - '0'; int num = big * 10 + small; if (num <= 26) { res.append(table[num]); i++; } else { res.append(table[big]); } } System.out.print(res); } } ```
查看全文
2 0 1 11
kaisyuantseng 题解分享 · 2024/4/11
字符串编号(编程题) - 题解
```cpp #include <bits/stdc++.h> using namespace std; #define int long long // #define LL long long #define endl '\n' void solve() { string s; cin >> s; for (int i = 0; i < s.length(); i++) { int num = stoi(s.substr(i, 2)); if (num <= 26) { printf("%c", 'A' + num - 1); i++; } else printf("%c", 'A' + (s[i] - '0') - 1); } } signed main() { // ios::sync_with_stdio(0); // cin.tie(0), cout.tie(0); solve(); return 0; } ```
查看全文
2 0 0 17
itlinyi 题解分享 · 2024/4/11
字符串编号(编程题) - 题解
``` // // Created by 30945 on 2024/4/11. // #include<bits/stdc++.h> #define int long long #define endl '\n' using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; getline(cin, s); for (int i = 0; i < s.length(); ++i) { char c; string a = s.substr(i, 2); if (stoi(a) <= 26) { c = stoi(a) + ('A' - 1); i++; } else { string a = s.substr(i, 1); c = stoi(a) + ('A' - 1); } cout << c; } return 0; } ```
查看全文
2 0 0 12
Liopen 题解分享 · 2024/4/13
字符串编号(编程题) - 题解
``` #include<cstdio> #include<iostream> #include<string> using namespace std; int main(){ string s; cin>>s; int one,two; char a[27]; for (int i=1;i<=26;++i){ a[i]= 'A'+i-1; } for(int i=0;i<s.length();i++){ one=s[i]-'0'; if(i!=s.length()-1) two=10*one+s[i+1]-'0'; if(two<=26&&two!=0){ cout<<a[two]; i++; two=0; } else{ cout<<a[one]; } } return 0; } ```
查看全文
2 0 0 7
less 题解分享 · 2024/4/6
字符串编号(编程题) - 题解
include using namespace std; int main() { string s; getline(cin, s); char m; int n = s.size(); ``` int i; for (i = 0; i < n; i++) { if (s[i] == '1' && s[i + 1] <= '9' && s[i + 1] >= '0') { m = 'A' + 10 + s[i + 1] - '1'; i++; cout << m; } else if (s[i] == '2' && s[i + 1] <= '6' && s[i + 1] >= '0') { m = 'A' + 20 + s[i + 1] - '1'; i++; cout << m; } else { m = 'A' + s[i] - '1'; cout << m; } } return 0; ``` }
查看全文
2 0 0 5
2835778687 题解分享 · 2024/4/9
字符串编号(编程题) - 题解
``` #include <iostream> #include <cstring> using namespace std; int main() { string str; cin>>str; int len=str.size(); for(int i=0;i<len;i++) { int a=str[i]-'0',c=stoi(str.substr(i,2)); if(c>26) { cout<<(char)(a+'A'-1); } else { i++; cout<<(char)(c+'A'-1); } } } ```
查看全文
1 0 1 15