?? 3_4.txt
字號:
#include<stdio.h>
typedef struct node{ /*結點類型*/
int data;
struct node *next;
}Llist;
createlist(Llist **h,int a[],int n)
{
int i;Llist *s,*r;
for(i=0;i<n;i++) /*在表尾插入結點*/
{
s=(Llist *)malloc(sizeof(Llist));
s->data=a[i];
s->next=NULL;
if(*h==NULL){*h=s;
r=s;}
else { r->next=s;
r=s;}
}
}
inverse(Llist **a)
{
Llist *h,*p,*q;
h=*a;
if(h==NULL) return 0;
else{ /*在表頭插入*/
p=h->next;
h->next=NULL;
while(p){
q=p->next;
p->next=h;
h=p;
p=q;
}
}
*a=h;
}
main()
{
int a[]={-1,2,3,5,7,10};
Llist *a1=NULL,*p;
createlist(&a1,a,6); /*建立鏈表A*/
inverse(&a1);
p=a1;
while(p){
printf("%d ",p->data);
p=p->next;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -