首页 > 试题广场 >

后缀子串排序

[编程题]后缀子串排序
  • 热度指数:15462 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
对于一个字符串,将其后缀子串进行排序,例如grain 其子串有: grain rain ain in n 然后对各子串按字典顺序排序,即: ain,grain,in,n,rain

输入描述:
每个案例为一行字符串。


输出描述:
将子串排序输出
示例1

输入

grain

输出

ain
grain
in
n
rain
头像 BrianWu
发表于 2021-07-06 18:08:51
/*描述对于一个字符串,将其后缀子串进行排序,例如grain 其子串有: grain rain ain in n 然后对各子串按字典顺序排序,即: ain,grain,in,n,rain输入描述:每个案例为一行字符串。输出描述:将子串排序输出*/ #include <iostream> 展开全文
头像 烤肉__
发表于 2022-01-21 12:15:18
善用STL #include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std; int main() { stri 展开全文
头像 DioDid
发表于 2022-02-05 21:58:01
分析一下本题 能够很轻松得获得子串 可以用排序交换的方法来解决问题 也可以直接用c语言自带的qsort方法 要用qsort的话,就要动态分配内存来定义数组 并且尤其要注意内存的释放 最后就是用cpp的vector容器和sort函数的方法 法1:排序交换 //法1:排序交换 #include < 展开全文
头像 机试秒杀者
发表于 2025-03-15 14:23:26
#include<bits/stdc++.h> using namespace std; // 比较两个字符串的大小 bool isbigger(const string& a, const string& b) { return a > b; // 直接 展开全文
头像 汉武帝刘彻
发表于 2025-03-22 19:36:25
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new S 展开全文
头像 heK10
发表于 2025-03-17 11:06:34
#include <algorithm> #include <iostream> using namespace std; int main() { string s;cin>>s; string str[100]; int len=s. 展开全文
头像 Ethan_G1615
发表于 2023-05-03 21:09:10
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<string> strs; int main() { string 展开全文
头像 宁静的冬日
发表于 2022-03-05 10:06:33
【C++】已通过 ">#include<string> #include<algorithm> using namespace std; #define MAX 1024 string suffix[MAX]; //按字典顺序排序 bool CMP(string a,stri 展开全文
头像 whoway
发表于 2020-12-07 10:03:18
#include<bits/stdc++.h> using namespace std; int main() { string str; while( cin>>str ) { int len=str.size(); 展开全文
头像 机试秒杀者
发表于 2025-03-15 12:23:34
#include<bits/stdc++.h> using namespace std; // 比较两个字符串的大小 bool isbigger(const string& a, const string& b) { return a > b; // 直接 展开全文

问题信息

难度:
125条回答 14572浏览

热门推荐

通过挑战的用户

查看代码
后缀子串排序