顶楼上!
因为有了因为,所以有了所以,既然已成既然,何必再说何必
#include <stdio.h> struct Node { int num; Node *next; }; Node * head; void Create(Node *pnode,int n,int a[]) { if(0 == n) return ; Node *p = head->next; Node *q = head; while(p) { if(a[0]>=p->num && p->next) { if(a[0]<=p->next->num) break; } q = p; p = p->next; } if(!head->next || a[0]<=head->next->num) { Node *temp = head->next; head->next = new Node; head->next->num = a[0]; head->next->next = temp; } else if(!p && q) { q->next = new Node; q->next->next = NULL; q->next->num = a[0]; } else { Node *temp = p->next; p->next = new Node; p->next->next = temp; p->next->num = a[0]; } Create(p,n-1,a+1); } int main() { head = new Node; head->next = NULL; int a[10] = {8,9,7,1,4,7,3,5,2,10}; Create(head,10,a); Node *p = head->next; while(p) { printf("%d ",p->num); p = p->next; } return 0; }感觉自己写的好迁就 楼主将就看吧 其实就是插入头部 中间 尾部 希望能帮助你