| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 387 人关注过本帖
标题:怎么调用输出函数,写个主函数测试,有错误,各位帮忙修改下。
只看楼主 加入收藏
gpf
Rank: 2
等 级:论坛游民
帖 子:24
专家分:25
注 册:2013-11-12
结帖率:88.89%
收藏
已结贴  问题点数:10 回复次数:5 
怎么调用输出函数,写个主函数测试,有错误,各位帮忙修改下。
#include<stdio.h>
#include<stdlib.h>
struct londe
{
    int data;
    londe *next;
}Londe,*head,*l;
void creat()
{
    int x;
    londe *p;
    head=NULL;
    int n,i=0;
    scanf("%d",&n);
    printf("输入n:%d\n",n);
    p=(struct londe*)malloc(sizeof(Londe));
    while(p->next!=NULL&&i<n)
    {        
        scanf("%d",&x);
        i++;
        p->data=x;
        p->next=l->next;
        l->next=p;
        p=(struct londe*)malloc(sizeof(Londe));
    }
}
void output()
{  
    londe *current=head->next;
    while(current)
    {
    printf("%d\n",current->data);
    current=current->next;
    }
}
int main()
{   
     void creat();
     void output();
        return 0;
}


搜索更多相关主题的帖子: current include 
2013-11-14 16:39
heroinearth
Rank: 10Rank: 10Rank: 10
来 自:云南曲靖
等 级:青峰侠
帖 子:430
专家分:1506
注 册:2011-10-24
收藏
得分:0 
int main()
{   
     void creat();//这是声明还是调用?
     void output();//这里也是
        return 0;
}
我的编译器不支持,无法帮你调试

[ 本帖最后由 heroinearth 于 2013-11-14 16:47 编辑 ]
2013-11-14 16:45
gpf
Rank: 2
等 级:论坛游民
帖 子:24
专家分:25
注 册:2013-11-12
收藏
得分:0 
回复 2楼 heroinearth
是声明,不是调用
2013-11-14 17:02
heroinearth
Rank: 10Rank: 10Rank: 10
来 自:云南曲靖
等 级:青峰侠
帖 子:430
专家分:1506
注 册:2011-10-24
收藏
得分:10 
程序代码:
/* Note:Your choice is C IDE */
#include<stdio.h>
#include<stdlib.h>
struct londe
{
    int data;
    struct londe *next;
}Londe,*head=NULL;
void creat()
{
    int x;
    struct londe *p,*l;
    int n,i=0;
    scanf("%d",&n);
    printf("输入n:%d\n",n);
    //p=(struct londe*)malloc(sizeof(Londe));
    while(i<n)
    {       
        scanf("%d",&x);
        p=(struct londe*)malloc(sizeof(Londe));
        p->next=NULL;
        p->data=x;
        if(head==NULL)
        {
            head=p;
            l=p;
                    
        }
        else
        {
            l->next=p;
            l=p;
        }
        i++;
       
       
    }
}
void output()
{ 
    londe *current=head;
    while(current)
    {
    printf("%d\n",current->data);
    current=current->next;
    }
}
int main()
{  
     creat();
     output();
     return 0;
}


[ 本帖最后由 heroinearth 于 2013-11-14 18:09 编辑 ]
2013-11-14 17:51
天楚
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:楚地
等 级:小飞侠
帖 子:550
专家分:2113
注 册:2013-3-14
收藏
得分:0 
额额额额额额

没有哪条路好走,选择了,就坚持下去~~~~
2013-11-14 18:57
gpf
Rank: 2
等 级:论坛游民
帖 子:24
专家分:25
注 册:2013-11-12
收藏
得分:0 
回复 4楼 heroinearth
谢谢
2013-11-14 21:51
快速回复:怎么调用输出函数,写个主函数测试,有错误,各位帮忙修改下。
数据加载中...
 
   



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

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