📄 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 + -