#include #include #include #include

using namespace std;

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

vector getSuffixSubstrings(string str) { vector result; int len = str.length(); for (int i = 0; i < len; i++) { result.push_back(str.substr(i)); } return result; }

int main() { string input; while (cin >> input) { vector suffixSubstrings = getSuffixSubstrings(input); sort(suffixSubstrings.begin(), suffixSubstrings.end(), compare); for (string str : suffixSubstrings) { cout << str << endl; } } return 0; }

字符串后缀子串排序 - C++ 实现

原文地址: http://www.cveoy.top/t/topic/iPh2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录