【C++】已通过

#include<string>
#include<algorithm>
using namespace std;
#define MAX 1024
string suffix[MAX];
//按字典顺序排序
bool CMP(string a,string b) {
	bool ret =true;
	int index = 0;
	while (index < a.size() && index < b.size()) {
		if (a[index] != b[index]) {
			ret = (a[index] < b[index]);
			break;
		}
		index++;
	}
	return ret;
}
int main() {
	string s; cin >> s;
	//suffix[0] = s;
	//int n = s.size();
	for (int i = 0;i<s.size(); i++) {
		suffix[i] = s.substr(i, s.size()-i);
	}
	sort(suffix, suffix + s.size(), CMP);
	for (int i = 0; i < s.size(); i++) {
		cout << suffix[i] << endl;
	}

	return 0;
}