单链表问题 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
相关问答:
在ue中从远程unix用二进制方式下载c文件到本地,修改之后用二进制方式上传到unix中,再用vi打开该文件,每行后面就会有一个^M的换行符,如果采用ascii方式下载,二进制方式上传的话就没有^M,那请问这样会对程序文件 ......
大家帮我看看这个代码,有很多问题,不知道怎么改,小弟在此谢谢了。
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
float date1,date2;
char op;
void ......
运行环境是unix,我用ue以ftp方式连到unix上,然后在ue中编写c程序,但在unix下用vi看程序时,每行后面都多了一个^M,这个应该是unix的换行符,每次只能删除一遍然后才能编译,否则会报错,请问这是在ue中字符编码的 ......
写了一段程序
C/C++ code:
..
MYSQL* mysql;
MYSQL_RES* res;
//我想实现一个查看有没有 mysql结构,如果没有就连接。
void connect()
{
mysql_init(mysql);
mysql_realconnect(. ......
下面是我的代码 从内存写入文件正确 但从文件读入内存都是乱码 而且程序崩溃 请c高手指点
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct inf
{
& ......