文章

1

粉丝

0

获赞

0

访问

105

头像
字符串排序2 题解:链表解
P1255 北京大学机试题
发布于2025年3月16日 17:24
阅读数 105

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

typedef struct node{
    char e;
    struct node *link;
}Node;

Node* getNode(char e){
    Node *node = (Node*)malloc(sizeof(Node));
    node->e = e;
    node->link = NULL;
    return node;
}

bool isChar(char x){
    return x >= 'a' && x <= 'z' || x >= 'A' && x <= 'Z';
}

Node* createLink(const char str[], int n){
    Node *head = getNode('#');
    Node *p = head;
    for(int i = 0; i < n; i++){
        Node *q = getNode(str[i]);
        p->link = q;
        p = p->link;
    }
    return head;
}

bool cmp(char x, char y){
    int step = &...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发