| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 679 人关注过本帖
标题:困扰我一星期的数据链表的问题
只看楼主 加入收藏
gyu130
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-6-10
收藏
 问题点数:0 回复次数:0 
困扰我一星期的数据链表的问题
源码如下:
#include <stdlib.h>
#include <stdio.h>

struct node
{
    int d[5];
    struct node *next;
};

struct node  *lookst(struct node *head,int x)                   //&sup2;é&Otilde;&Ograve;
{
struct node *p;
p=head;
while((p->next!=NULL)&&((p->next)->d[5])!=x)p=p->next;
return(p);        
}
    
inslst(struct node **head,int x,int b)                          //&sup2;&aring;&Egrave;&euml;
{
    struct node *p,*q ;
    p=(struct node *)malloc(sizeof(struct node));
    p->d[5]=b;
    if(*head==NULL)
        {
            *head=p;
            p->next=NULL;
            return 0;
            }
    if((*head->d[5])==x)
    {
        p->next=*head;
        *head=p;
        return 0;
        }
    q=lookst(*head,x);
    p->next=q->next;
    q->next=p;
    return 0;
    }
    
delst(struct node **head,int x)
{
struct node *p,*q;
if(*head==NULL)
    {
    printf("This is a empty list !\n");    
    return 0;
    }    
if((*head->d[5])==x)
    {
    p=*head->next;
    free(*head);
    *head=p;
    return 0;    
    }    
q=lookst(*head,x);
if(q->next==NULL)
    {
    printf("No this node in the list!\n");
    return 0;    
    }
p=q->next;q->next=p->next;
free(p);    
return 0;
}



main()
  {
        int i,n,d[5];
        struct node *m;
        printf("the input number:\n");
        for(i=0;i<5;i++)
        scanf("%d",&d[i]);
        printf("\n");
        printf("please input the insert number:\n");
        scanf("%d",&n);
        lookst(m,4);
        inslst(&m,3,5);
        for(i=0;i<6;i++)
        printf("%d",&d[i]);
        delst(&m,5);
        for(i=0;i<6;i++)
        printf("%d",&d[i]);
    }


以上程序编译报错:
C:\Documents and Settings\dell\×&Agrave;&Atilde;&aelig;\data\4.c(29) : error C2223: left of '->d' must point to struct/union
C:\Documents and Settings\dell\×&Agrave;&Atilde;&aelig;\data\4.c(49) : error C2223: left of '->d' must point to struct/union
C:\Documents and Settings\dell\×&Agrave;&Atilde;&aelig;\data\4.c(51) : error C2223: left of '->next' must point to struct/union
不知如何解决,希望高人指点哈!
搜索更多相关主题的帖子: 链表 困扰 数据 
2008-10-22 18:38
快速回复:困扰我一星期的数据链表的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024579 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved