ZJANS

d570. 神龍見首不見尾

Easy Last Update: 2026/02/01
字串

給一個正整數 n
逐次去掉尾數並顯示出來


解法一、字串

✅ 完整代碼

評分結果(參考) : AC (1ms, 324KB)

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string n;
    cin >> n;
    
    for(int i=0; i<n.size(); i++){
        for(int j=0; j<n.size()-i; j++){
            cout << n[j];
        }
        cout << "\n";
    }
    
    return 0;
}