单链表问题 c高手请进
编写一个程序用链表实现:将一个升序整数数列的重复数据去掉
编好后,结果不对啊,求助c高手
#include <stdio.h>
#include <stdlib.h>
struct link
{
int number;
struct link *next;
};
struct link* creat()
{
struct link *p1,*p2;
struct link *head;
int n=0;
p1=p2=(struct link*)malloc(sizeof(struct link));
scanf("%d",&p2->number);
head=NULL;
while(p2->number!=0)
{
n++;
if(n==1)
head=p1;
else
{
p1->next=p2;
p1=p2;
}
p2=(struct link *)malloc(sizeof(struct link));
scanf("%d",&p2->number);
}
p1->next=NULL;
return head;
}
/struct link *del(struct link *head)
{
struct link *p1,*p2;
if(head==NULL)
printf("link is empty!");
p1=p2=head;
if(p1->next==NULL)
printf("needn't sort!");
else
{
while(p1->next!=NULL)
{
p1->next=p2;
if(p1->number==p2->number)
{
&nb
相关问答:
在查询后将查询出来的值赋给各输入框
<c:if test="${not empty dataValue}">
fm.SAMPLING_DATE.value=" <c:out value='${dataValue.SAMPLING_DATE}'/ ......
开始学OS,按练习要求写的代码在gcc下无法编译:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
void SIGFPEhandler2(int s ......
C/C++ 2009-9专家榜
名次 专家名称 专家分 个人描述
1 mstlq (面色铁路桥) 5843 因为菜,所以努力学习中
2 whg01 (及时结贴是美德)&n ......
下面是我的代码 从内存写入文件正确 但从文件读入内存都是乱码 而且程序崩溃 请c高手指点
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct inf
{
& ......