易截截图软件、单文件、免安装、纯绿色、仅160KB

单链表问题 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基础

#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 和b/s 的区别是什么,c/s需要服务器吗,怎么判断程序是c/s 还是b/s
C/S是服务器和客户端    B/S是服务器和浏览器

他们都有s,什么是s?就是server
那他们的区别是什么?一个是c,即client,一个 ......

【★C/C++奖励基金-3期★】

C/C++  2009-9专家榜
名次  专家名称  专家分  个人描述 
1  mstlq (面色铁路桥)  5843  因为菜,所以努力学习中 
2  whg01 (及时结贴是美德)&n ......

C中内存的分配

比如:
char c[] = "hello,world";
char *c = "hello,world";

在分配内存时是不一样的吧?(分配到堆还是栈什么的)
谁能给讲讲C中内存是怎么分配的啊?
或者给提供个链接 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号