#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
bool cmp(string a,string b)
{
return a<b;
}
int main()
{
string str;
getline(cin,str);
vector<string> postfix;
for(int i=0;i<str.length();++i){
string s=str.substr(i);//表示从下标i开始一直到结束
postfix.push_back(s);
}
sort(postfix.begin(),postfix.end(),cmp);
for(int j=0;j<postfix.size();++j)
cout << postfix[j] << endl;
return 0;
}
牛客网——后缀子串排序
最新推荐文章于 2023-07-12 18:17:36 发布