单原点最短路径算法与实现(3 页)Good is good, but better carries it
精益求精,善益求善
#include#includestruct linknode{ int data; struct linknode *next;};struct linknode *create( int n)//创建单链表{ int d; int i=1,j=0; struct linknode *head,*s,*t; head=NULL; printf("建立一个单链表:\n"); printf("请输入数字:\n"); printf("数据%d:",i); scanf("%d",&d); head=(struct linknode *)malloc(sizeof(struct linknode)); head->data=d; head->next=NULL; t=head; //建立第一个结点 for(j=1;jdata=d; s->next=NULL; t->next=s; t=s; if(i==n) { printf("数据输入完毕
\n"); break; } } return head;}void disp(struct linknode *head)//输出结点数据{ struct linknode *p=head; printf("输出一个单链表:\n"); if(p==NULL) printf("空"); while(p
=NULL) { printf("%d\n",p->data); p=p->next; } printf("\n");}struct linknode *invert(struct linknode *head){ struct linknode *p,*q,*r; p=head; q=p->next; while(q