| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 464 人关注过本帖
标题:简单的链表问题 哎 还是不行啊 大家一起来帮帮忙啊 3q了
取消只看楼主 加入收藏
吴小杰
Rank: 3Rank: 3
来 自:。。。。。。
等 级:论坛游侠
帖 子:58
专家分:107
注 册:2011-11-11
结帖率:100%
收藏
已结贴  问题点数:14 回复次数:1 
简单的链表问题 哎 还是不行啊 大家一起来帮帮忙啊 3q了
运行的时候一直是输入   没有输出

#include <stdio.h>
#include <malloc.h>
#define  NULL 0   //这里出现了redefined
#define LEN sizeof(struct student)
struct student
{
    long num;
    char name[20];
    char sex[6];
    float score[3];
    struct student*next;
};
int main ()
{
    int n=1;
    struct student *head,*p1,*p2;
    head=p1=p2=(struct student*)malloc(LEN);
    scanf("%d %s %s %f %f %f",&p1->num,
                              p1->name,
                              p1->sex,
                              &p1->score[0],
                              &p1->score[1],
                              &p1->score[2]);//format '%d' expects type 'int *', but argument 2 has type 'long int *'
    while(p1->num!=0)
    {
        if(n>1)
            p2->next=p1;
        p2=p1;
        n++;
        p1=(struct student*)malloc(LEN);
        scanf("%d %s %s %f %f %f",&p1->num,
                                   p1->name,
                                   p1->sex,
                                   &p1->score[0],
                                   &p1->score[1],
                                   &p1->score[2]);// &p1->score[2]这句出现了format '%d' expects type 'int *', but argument 2 has type 'long int *'
    }
    p1=NULL;
    p1=head;
    if(p1!=NULL)
        do
        {
            printf("%d %s %s %f %f %f",&p1->num,
                                      p1->name,
                                      p1->sex,
                                      &p1->score[0],
                                      &p1->score[1],
                                      &p1->score[2]);//format '%d' expects type 'int *', but argument 2 has type 'long int *'
            p1=p1->next;
        }while(p1!=NULL);
    return 0;
}
搜索更多相关主题的帖子: include 
2011-12-03 22:59
吴小杰
Rank: 3Rank: 3
来 自:。。。。。。
等 级:论坛游侠
帖 子:58
专家分:107
注 册:2011-11-11
收藏
得分:0 
急啊   
2011-12-03 23:09
快速回复:简单的链表问题 哎 还是不行啊 大家一起来帮帮忙啊 3q了
数据加载中...
 
   



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

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