文章

17

粉丝

0

获赞

5

访问

1.3k

头像
后缀子串排序 题解:字符串切片+vector
P1294 上海交通大学机试题
发布于2025年5月30日 14:21
阅读数 14

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

void StrSort(const string &s,vector<string> &vec){
    for(int i=0;i<s.length();i++){
        vec.push_back(s.substr(i));
    }
    stable_sort(&vec[0],&vec[vec.size()]);

int main(){
    string str;
    while(cin>>str){
        vector<string> vec;
        StrSort(str,vec);
        for(auto x:vec){
            cout<<x<<endl;
        }
    }
    return 0;

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发