C 简单连表

来源:百度知道 编辑:UC知道 时间:2024/06/06 19:15:25
帮我看看下面这个程序怎么运行的时候老是错了?

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
//线性表的链式存储结构定义
struct node

{
int info;
struct node* link;
}*h1,*p,*q,*r,*h2;

//typedef struct node *pnode;

void creatList1(struct node *A)//尾插法建立连表
{

char key;
if(!(h1=(node *)malloc(sizeof(node))))return;
h1=A;
h1->link=NULL;
r=h1;
printf("\n建立连表成功\n");
printf("输入集合1: \n");
do
{
p=(node *)malloc(sizeof(node));
printf("\n输入: ");
scanf("%d",&p->info);
r->link=p;
p->link=NULL;
r=p;
printf("\n继续增加(1/0)?");
key=getch();
}while(key=='1');
}
void creatList2(struct node *B)//尾插法建立连表
{

char

发现了一个错误:
void creatList1(struct node *A)//尾插法建立连表
{

char key;
if(!(h1=(node *)malloc(sizeof(node))))return;
h1=A; //此处应为A=h1啊
接下来的你自己找吧