题目链接
https://www.patest.cn/contests/pat-b-practise/1006
代码
#include<iostream>
#include<stack>
using namespace std;
int main() {
char a[2] = {'S', 'B'};
int n, x;
stack<int> s;
cin >> n;
while(n != 0) {
s.push(n % 10);
n /= 10;
}
while(!s.empty()) {
for(int i=0; i < s.top(); i++) {
if(s.size() == 1) {
for(int j = 1; j <= s.top(); j++) cout << j;
break;
}
else cout << a[s.size() - 2];
}
s.pop();
}
return 0;
}
本文介绍了PAT在线编程比赛中的一道题目,涉及将整数以特定格式输出的问题。提供了题目链接及解决该问题的代码实现。
567

被折叠的 条评论
为什么被折叠?



