题解 | #后缀子串排序#
后缀子串排序
https://www.nowcoder.com/practice/f89f96ea3145418b8e6c3eb75773f65a
#include<cstdio> #include<vector> #include<string> #include<algorithm> using namespace std; bool comp(string lhs ,string rhs){ return lhs < rhs; } int main(){ char arr[100]; scanf("%s",arr); string str = arr; int len = str.size(); vector<string> vec; for(int i = len-1 ; i >=0 ;--i){ vec.push_back(str.substr(i)); } sort(vec.begin(),vec.end(),comp); int len1 = vec.size(); for(int i = 0 ; i < len1 ;++i){ printf("%s\n",vec[i].c_str()); } }