文章

4

粉丝

497

获赞

3

访问

33.3k

头像
链表构造+排序+遍历输出
P1405 华中科技大学
发布于2020年7月5日 21:13
阅读数 8.9k

#include<bits/stdc++.h>
using namespace std;
struct node{
    int num;
    struct node *next;
};
struct node * create(){
    struct node *head;
    head = (struct node*)malloc(sizeof(node));
    head->num = -1;
    head->next = NULL;
    return head;
}
void print(struct node* head){
    for(struct node *p = head->next;p!=NULL;p = p->next)
        cout<<p->num<<" ";
}
void sortlinklist(struct node *head){
    for(struct node *pp = head->next;pp->next!=NULL;pp = pp->next){
        for(struct node *pre = pp,*p = pre->next;p!=NULL;p = p->next){
            if(pre->num>p->num){
                int tmp = pre...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发