单链表问题 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
相关问答:
#include <string.h>
#include <stdio.h>
void main()
{
int i;
char buf[]="abcde";
strncpy(buf,"abc",3);
for(i=0;i <5;i++)
printf(&q ......
c/s 和b/s 的区别是什么,c/s需要服务器吗,怎么判断程序是c/s 还是b/s
C/S是服务器和客户端 B/S是服务器和浏览器
他们都有s,什么是s?就是server
那他们的区别是什么?一个是c,即client,一个 ......
/*-----------c.h--------------*/
#ifndef _C_H_
#define _C_H_
extern "C" int add(int x, int y);
#endif
/*-----------c.c--------------*/
int add(int x, int y){
return ......
运行环境是unix,我用ue以ftp方式连到unix上,然后在ue中编写c程序,但在unix下用vi看程序时,每行后面都多了一个^M,这个应该是unix的换行符,每次只能删除一遍然后才能编译,否则会报错,请问这是在ue中字符编码的 ......
以前在VC里面建一个工程,都只用一个 .c 文件,昨天在一个工程里用了两个 .c文件了,遇到问题了,请大家指点。比如:
File1.c Fil ......