文章

34

粉丝

0

获赞

244

访问

4.2k

头像
后缀子串排序 题解:
P1294 上海交通大学机试题
发布于2026年3月9日 15:57
阅读数 70

#include <bits/stdc++.h>
using namespace std;

bool compareword(char *a,char *b){
    return strcmp(a,b)<0;
}

int main(){
    char s[100];
    while(scanf("%s",s)!=EOF){
        int len=strlen(s);
        char* suffice[100];
        for(int i=0;i<len;i++){
            suffice[i]=&s[i];
        }
        stable_sort(suffice,suffice+len,compareword);
        for(int i=0;i<len;i++){
            printf("%s\n",suffice[i]);
        }
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发