文章

94

粉丝

0

获赞

547

访问

17.0k

头像
后缀子串排序 题解: c++
P1294 上海交通大学机试题
发布于2026年2月10日 14:55
阅读数 122

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

bool cmp(string a,string b){
    return a < b;
}

int main(){

    string s;
    while(cin >> s){
        vector<string> str;
        str.push_back(s);
        for(int i = 1; i < s.size(); i++){
            str.push_back(s.substr(i));
        }
        sort(str.begin(),str.end(),cmp);
        for(string i : str){
            cout << i << endl;
        }
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发