思路:
sort排序函数执行一次,将链表俩俩之间比较大小,比较之后,大的在后,小的在前(链表节点之间只交换内容,节点不动)。只有链表的所有俩俩相邻之间都是小的在前,大的在后,才返回true,否则返回false。while(sort(head));
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "string.h" typedef struct node{ int elem; struct node *next; }NODE; void main(int argc,char *argv[]) { int num[] = { 5,3,6,8,1