文章

82

粉丝

343

获赞

27

访问

663.2k

头像
字符串数组
P1294 上海交通大学机试题
发布于2021年1月24日 18:27
阅读数 7.5k

#include <bits/stdc++.h>
using namespace std;
//字符串数组不能直接写成char[][]这样会被理解成二维字符类型数组
//通过构造结构体数组,每个结构体中存放一个char[]即可 
char s[105];
struct node{
    char s[105];
};
node a[105];
bool cmp(node x,node y){
    if(strcmp(x.s,y.s)<0) return true;
    else return false;
}
int main(){
    while(scanf("%s",&s)!=EOF){
        int len=strlen(s);
        for(int i=0;i<len;i++){
            int index=0;
            for(int j=i;j<len;j++){
                a[i].s[index++]=s[j];            
            }
        }
        sort(a,a+len...

登录查看完整内容


登录后发布评论

4 条评论
玖拾伍
2021年1月25日 12:17

啊这

赞(0)
玖拾伍
2021年1月25日 12:17

啊这

赞(0)

James : 回复 玖拾伍: 咋啦老哥 直接用string其实更好做哈哈

2021年1月26日 19:06

玖拾伍 : 回复 James: 不好意思[挠头],就是尝试着评论了一下[doge]

2021年1月26日 20:57