大家帮我看看这个程序错误在哪?怎么改呢?#include "stdio.h"#include "malloc.h"#include "windows.h"typedef struct _Node{ char name[6]; char tel[8]; struct _Node *next;}Node,*List;void InitNode(List L){ if((L=(List)malloc(sizeof(Node)))=
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/05 06:12:01
![大家帮我看看这个程序错误在哪?怎么改呢?#include](/uploads/image/z/3169412-44-2.jpg?t=%E5%A4%A7%E5%AE%B6%E5%B8%AE%E6%88%91%E7%9C%8B%E7%9C%8B%E8%BF%99%E4%B8%AA%E7%A8%8B%E5%BA%8F%E9%94%99%E8%AF%AF%E5%9C%A8%E5%93%AA%3F%E6%80%8E%E4%B9%88%E6%94%B9%E5%91%A2%3F%23include+%22stdio.h%22%23include+%22malloc.h%22%23include+%22windows.h%22typedef+struct+_Node%7B+char+name%5B6%5D%3B+char+tel%5B8%5D%3B+struct+_Node+%2Anext%3B%7DNode%2C%2AList%3Bvoid+InitNode%28List+L%29%7B+if%28%28L%3D%28List%29malloc%28sizeof%28Node%29%29%29%3D)
大家帮我看看这个程序错误在哪?怎么改呢?#include "stdio.h"#include "malloc.h"#include "windows.h"typedef struct _Node{ char name[6]; char tel[8]; struct _Node *next;}Node,*List;void InitNode(List L){ if((L=(List)malloc(sizeof(Node)))=
大家帮我看看这个程序错误在哪?怎么改呢?
#include "stdio.h"
#include "malloc.h"
#include "windows.h"
typedef struct _Node
{
char name[6];
char tel[8];
struct _Node *next;
}Node,*List;
void InitNode(List L)
{
if((L=(List)malloc(sizeof(Node)))==NULL)
exit(-1);
L->next=NULL;
}
void AddNode(List L)
{
if((List p=(List)malloc(sizeof(Node)))==NULL)
exit(-1);
printf("Input Name:\n")
scanf("%s",p->name);
printf("Input Tel:\n")
scanf("%s",p->tel);
List p1=L->next,p2=L;
while(p1->next && strcmp(name,p->name)>0)
{
p1=p1->next;
p2=p2->next;
}
p->next=p2->next;
p1->next=p;
}
void PrintNode(List L)
{
List p=L->next;
while(p)
{
printf("name: %s\t\tTel: %s\n",p->name,p->tel);
p=p->next;
}
}
void main()
{
List L;
InitNode(L);
for(int i=0;i
大家帮我看看这个程序错误在哪?怎么改呢?#include "stdio.h"#include "malloc.h"#include "windows.h"typedef struct _Node{ char name[6]; char tel[8]; struct _Node *next;}Node,*List;void InitNode(List L){ if((L=(List)malloc(sizeof(Node)))=
很多分号没打
exit函数没有定义
while(p1->next && strcmp(name,p->name)>0) name是哪个节点的数据没有指明
改了一下~lz试调一下
#include "stdio.h"
#include "malloc.h"
#include "windows.h"
typedef struct _Node
{
char name[6];
char tel[8];
struct _Node *next;
}Node,*List;
void InitNode(List L)
{
if((L=(List)malloc(sizeof(Node)))==NULL)
exit(-1);
L->next=NULL;
}
void AddNode(List L)
{
List p=(List)malloc(sizeof(Node));
if(p==NULL)
{
printf("Error!\n");
return;
}
printf("Input Name:\n");
scanf("%s",p->name);
printf("Input Tel:\n");
scanf("%s",p->tel);
List p1=L->next,p2=L;
while(p1->next && strcmp(p1->name,p->name)>0)
{
p1=p1->next;
p2=p2->next;
}
p->next=p2->next;
p1->next=p;
}
void PrintNode(List L)
{
List p=L->next;
while(p)
{
printf("name:%s\t\tTel:%s\n",p->name,p->tel);
p=p->next;
}
}
void main()
{
List L;
InitNode(L);
for(int i=0;i