#include <stdio.h>typedef struct ListNode {int f; struct ListNode *next;} ListNode; ListNode *sort (ListNode *head) {ListNode *p,*p1,*p2,*p3; ListNode h, t; if (head = = NULL) return null; H.next=head; p=&h; while (p->next!=null) {p=p->next; } p=p->next=&t; while (P!=h.next) {p3=&h; p1=p3->next; p2=p1->next; while (p2!=p) {if ((p1->f) > (p2->f)) {p1->next=p2->next; p2->next=p1; p3->next=p2; P3=P2; p2=p1->next; } else {p3=p1; P1=P2; p2=p2->next; }} P=P1; } while (p->next!=&t) {p=p->next; } p->next=null; return h.next;} int main () {ListNode h,j,k,l; h.next=&j; h.f=3; j.next=&k; j.f=5; k.next=&l; k.f=1; L.next=null; l.f=7; listnode* p = sort (&h); while (P! = NULL) {printf ("%d", p->f); p=p->next; } printf ("\ n"); return 0;}
void Sort1 (ListNode *head) {ListNode *p, *q, *pt;p = Head;q = P->next;while (P->next! = null) {while (Q->next! = null {if (P->next->f > Q->next->f) {pt = P->next;p->next = Q->next;q->next = p->next->next; P->next->next = pt;} Elseq = Q->next;} p = p->next;q = P->next;}}
Sequencing of C-linked table switching nodes