| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 534 人关注过本帖
标题:三个学生五门课,通过函数调用输入,然后在主函数输出,但就是总是输出零. ...
只看楼主 加入收藏
静夜书生
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-3-18
收藏
 问题点数:0 回复次数:2 
三个学生五门课,通过函数调用输入,然后在主函数输出,但就是总是输出零.望指点
三个学生五门课,通过函数调用输入,然后在主函数输出,(已检查没错,语法也对.但就是不行)但就是总是输出零.望指点.
#include<stdio.h>
struct student
{
    int num;
    char name[10];
    float score[5];
};
struct student stu[3];
void input(struct student stu[] )
{
    int i;
    printf("please input ten students'name and scores\n");
    for (i=0;i<3;i++)
    {
        scanf("%d%s%f%f%f%f%f",&stu[i].num,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2],&stu[i].score[3]
        ,&stu[i].score[4]);
            }
}
int main()
{
    void input(struct student  stu[]);
    int i;
    input (stu);
    for (i=0;i<3;i++)
    {
        printf("%d%s%f%f%f%f%f",stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3]
            ,stu[i].score[4]);
        printf ("\n");

    }
    return(0);
}
搜索更多相关主题的帖子: 函数 学生 输出 输入 
2008-03-21 18:39
红影
Rank: 1
等 级:新手上路
威 望:2
帖 子:659
专家分:0
注 册:2006-2-22
收藏
得分:0 
大概看了一眼之后发现2个错误

#include<stdio.h>
struct student
{
    int num;
    char name[10];
    float score[5];
};
struct student stu[3];
void input(struct student stu[] )
{
    int i;
    printf("please input three students'name and scores\n");
    for (i=0;i<3;i++)
    {
        scanf("%d%s%f%f%f%f%f",&stu[i].num,[bo]&[/bo]stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2],&stu[i].score[3]
        ,&stu[i].score[4]);
            }
}
int main()
{
    void input(struct student  stu[]);
    int i;
    input (stu);
    for (i=0;i<3;i++)
    {
        printf("%d%s%f%f%f%f%f",stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3]
            ,stu[i].score[4]);
        printf ("\n");

    }
    return(0);
}

生命中,不断有人离开和进入。于是,看见的,看不见了;记住的,遗忘了。
2008-03-21 19:24
静夜书生
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-3-18
收藏
得分:0 
three is wrong ,但是在输入stu[i].name的时候是不需要加&,这点很确定.
2008-03-21 19:54
快速回复:三个学生五门课,通过函数调用输入,然后在主函数输出,但就是总是输出 ...
数据加载中...
 
   



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

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