| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 439 人关注过本帖
标题:大神,求解???
只看楼主 加入收藏
czwx
Rank: 1
等 级:新手上路
帖 子:6
专家分:3
注 册:2015-10-4
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
大神,求解???
下面的程序编译没问题,怎么运行不了啊?
#include <stdio.h>
#include <stdlib.h>
typedef int datatype;
struct linklist
{
    datatype data;
    struct linklist *next;
};
void creatlist(struct linklist *head)
{
    int i;
    struct linklist *p,*q;
    p=head;
    printf("请输入元素,输入0则停止:");
    scanf("%d",i);
    while(i!=0)
        {
            q=(struct linklist *)malloc(sizeof(struct linklist));
            q->data=i;q->next=NULL;
            p->next=q;
            p=q;
            scanf("&d",i);
        }
}
int insertllist(struct linklist *L,int b)
{
    int a;
    struct linklist *p,*s,*q;
    s=(struct linklist *)malloc(sizeof(struct linklist));
    s->data=b;
    if(L->next==NULL)
        {
            L->next=s;
            return 1;
        }
    q=L->next;
    while(q!=NULL)
        {
            if(b>q->data)
                {a=q->data;break;}
            else
                q=q->next;

        }
    p=L->next;
    while((p!=NULL)&&(p->data!=a))
        p=p->next;
    s->next=p->next;
    p->next=s;
    return 2;
}
void outputlinklist(struct linklist *head)
{
    struct linklist *q;
    q=head->next;
    while(q!=NULL)
        {
            printf("%d",q->data);
            q=q->next;
        }
}
void main()
{
    int x;
    struct linklist *head;
    head=(struct linklist *)malloc(sizeof(struct linklist));
    head->next=NULL;
    creatlist(head);
    printf("请输入要插入的数:");
    scanf("%d",&x);
    insertllist(head,x);
    outputlinklist(head);

   

}
搜索更多相关主题的帖子: include 元素 include 元素 
2015-10-04 17:25
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:8 
scanf("%d",i);

剑栈风樯各苦辛,别时冰雪到时春
2015-10-04 17:41
蓝色风暴cl
Rank: 8Rank: 8
来 自:新疆
等 级:蝙蝠侠
威 望:3
帖 子:163
专家分:704
注 册:2015-9-6
收藏
得分:8 
&符号没打??

欢迎大家加好友哦,多找我聊聊吧!
2015-10-04 19:26
the_second
Rank: 2
等 级:论坛游民
帖 子:115
专家分:80
注 册:2015-9-13
收藏
得分:4 
下面的程序编译没问题,怎么运行不了啊?
#include <stdio.h>
#include <stdlib.h>
typedef int datatype;
struct linklist
{
    datatype data;
    struct linklist *next;
};
void creatlist(struct linklist *head)
{
    int i;
    struct linklist *p,*q;
    p=head;
    printf("请输入元素,输入0则停止:");
    scanf("%d",i);
    while(i!=0)
        {
            q=(struct linklist *)malloc(sizeof(struct linklist));
            q->data=i;q->next=NULL;
            p->next=q;
            p=q;
            scanf("&d",i);
        }
}
int insertllist(struct linklist *L,int b)
{
    int a;
    struct linklist *p,*s,*q;
    s=(struct linklist *)malloc(sizeof(struct linklist));
    s->data=b;
    if(L->next==NULL)
        {
            L->next=s;
            return 1;
        }
    q=L->next;
    while(q!=NULL)
        {
            if(b>q->data)
                {a=q->data;break;}
            else
                q=q->next;

        }
    p=L->next;
    while((p!=NULL)&&(p->data!=a))
        p=p->next;
    s->next=p->next;
    p->next=s;
    return 2;
}
void outputlinklist(struct linklist *head)
{
    struct linklist *q;
    q=head->next;
    while(q!=NULL)
        {
            printf("%d",q->data);
            q=q->next;
        }
}
void main()
{
    int x;
    struct linklist *head;
    head=(struct linklist *)malloc(sizeof(struct linklist));
    head->next=NULL;
    creatlist(head);
    printf("请输入要插入的数:");
    scanf("%d",&x);
    insertllist(head,x);
    outputlinklist(head);

   

}
2015-10-05 00:04
快速回复:大神,求解???
数据加载中...
 
   



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

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