题解 | 后缀子串排序

#include<iostream>
#include<algorithm>
#include <string.h>
#include<vector>
using namespace std;

int main() {
	string s;
	cin >> s;
	vector<string> str;
	for (int i = 0; i < s.length(); i++) {
		str.push_back(s.substr(i, s.length()));
	}
	sort(str.begin(), str.end());
	for (int i = 0; i < s.length(); i++) {
		cout << str[i] << '\n';
	}
	
}

全部评论

相关推荐

快刀斩offer:干测试,项目组就我一个测试,准备在职考研跑路了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务