#55156: c++正解跟思路 (想學再點)


yp11451032@yphs.tp.edu.tw (711-23吳嘉恩)


#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int a;
    while(cin>>s){
        a=0;
        for(char c:s){               //逐一查看字串 s 當中的每一個字元
            if(isdigit(c)){          //是否是數字
                a+=c-'0';            //將字元轉換成整數數值並累加
            }else if(c=='!'){
                cout<<'\n';
            }else if(c=='b'){
                cout<<string(a,' '); //輸出a個空格
                a=0;
            }else{
                cout<<string(a,c);
                a=0;
            }
        }
        cout<<'\n';
    }
}