c语言问题,高手进来看一下嘛!急!急!

些程序的目的是:有两个链表a、b,从a链表中删去b链表中的有相同学号的那些结点。#include<stdio.h>#include<malloc.h>#include<c... 些程序的目的是:有两个链表a、b,从a链表中删去b链表中的有相同学号的那些结点。
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
#define LEN sizeof(struct student)
#define RUN 1
struct student
{
long num;
char name[10];
struct student *next;
};
int n = 0;

struct student *creat(void)
{
void print(struct student *head);
struct student *head;
struct student *p1, *p2;
p2 = p1 = (struct student *)malloc(LEN);
printf("input the num:");
scanf("%ld", &p1->num);
printf("input name:");
scanf("%s", &p1->name);
head = NULL;
while (p1->num != 0)
{
n += 1;
if (n == 1)
head = p1;
else
p2->next = p1;
p2 = p1;
p1 = (struct student *)malloc(LEN);
printf("input the num:");
scanf("%ld", &p1->num);
printf("input the name:");
scanf("%s", &p1->name);
}
p2->next = NULL;
return (head);
#if RUN
print(head);
#endif

}

void print(struct student *head)
{
struct student *p = head;
if (head != NULL)
{
while (p != NULL)
{
printf("%ld,%s\n", p->num, p->name);
p = p->next;
}
}
}

struct student *del(struct student *head, long num)
{
struct student *p1 = head, *p2;
if (head == NULL)
{
goto end;
}
while (num != p1->num && p1 != NULL)
{
p2 = p1;
p1 = p1->next;
}
if (num == p1->num)
{
if (p1 == head)
head = p1->next;
else
p2->next = p1->next;
}
else
printf("there is not num!\n");
end:
return (head);
}

main()
{
struct student *heada, *headb;
struct student *p;
printf("input the a:\n");
heada = creat();
printf("the a is:\n");
print(heada);
printf("input the b:\n");
headb = creat();
printf("the b is:\n");
print(headb);
p = headb;
while (p != NULL)
{
heada = del(heada, p->num);
p = p->next;
}
print(heada);
getch();
}
展开
 我来答
雪燕儿£
2007-05-19 · 超过42用户采纳过TA的回答
知道答主
回答量:322
采纳率:0%
帮助的人:0
展开全部
9209868
<br>到群里面问吧
<br>里面可能有会的
一剑飞雪(331012005) 23:04:53
刷代码?
Mr.Gentleman(215419355) 23:05:05
又链表`
雪燕儿(80239840) 23:05:34
刷积分
别人的问题
他不是找问题吗?
一剑飞雪(331012005) 23:05:43
template <class T>
bool listiterator<T>::NotNull()
{
return current != NULL;
}

template <class T>
bool listiterator<T>::NextNotNull()
{
return current!=NULL && current->link!=NULL;
}

template <class T>
T* listiterator<T>::First()
{
if (list.first!=NULL)
return &list.first->data;
return NULL;
}

template <class T>
T* listiterator<T>::Next()
{
if (current!=NULL)
{
current = current->link;

if (current!=NULL)
return ¤t->data;
}
return NULL;
}
一剑飞雪(331012005) 23:05:56
这次英文没有用错
一剑飞雪(331012005) 23:06:04
没有用interator
雪燕儿(80239840) 23:06:09
这个能用了?
vczh.theory.(343056143) 23:06:13
ListIterator
风流不老白云人s
2007-05-19 · 超过17用户采纳过TA的回答
知道答主
回答量:147
采纳率:0%
帮助的人:0
展开全部
.............好多吖..
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式