輸入不超過 3 位正整數 n。
百位數字 b → 輸出 b 個 'B'
十位數字 s → 輸出 s 個 'S'
個位數字 g → 輸出 1 到 g 的數字
g = n%10; s = n/10%10; b = n/100;#include <stdio.h>
int main() {
int n; scanf("%d", &n);
int b = n / 100;
int s = n / 10 % 10;
int g = n % 10;
for (int i=0; i
樣例
Input: 234
Output: BBSSS1234
Input: 23
Output: SS123
常見錯誤
- 未處理無百位/十位情況(循環 0 次即可)。
- 個位輸出從 0 開始(應從 1)。