#include <iostream> #include <string> #include <cstdio> #include <algorithm> using namespace std; string str;//定义子串,需要知道获取字串的长度的函数为str.length() int main() { cin >> str; int len = str.length();//len为str的长度 string s[len]; for (int i = 0; i < len; i++) { s[i] = str.substr(i);//如何获取str的字串:substr(); } string temp; for (int i = 0; i < len - 1; i++) { for (int j = 0; j < len - 1; j++) { if (s[j] < s[j + 1]) { temp = s[j]; s[j] = s[j + 1]; s[j + 1] = temp; } } } //排序完毕,输出字串; for (int i = len - 1; i >= 0; i--) cout << s[i] << endl; return 0; } // 64 位输出请用 printf("%lld")