标题:求助:关于一维数组的运用
取消只看楼主
szweifj
Rank: 2
等 级:论坛游民
帖 子:30
专家分:26
注 册:2010-2-10
结帖率:75%
已结贴  问题点数:20 回复次数:0 
求助:关于一维数组的运用
程序运行可以通过,但是显示 Math[MAX]和Average[MAX]的值均为 0,不太明白,请大家帮我看看是哪里错了,谢谢!!

#include<stdio.h>
#define MAX 50
void main()
{
    int StuNum,i,Chinese[MAX],Math[MAX],English[MAX];
    long StuID[MAX];
    float Average[MAX],AverClass;
    while(1)
    {
        printf("How many students are in your class?\n");
        scanf("%d",&StuNum);
        if(StuNum<1||StuNum>MAX)
        {
            printf("StudentNum must be between 1 and %d.Press any key to continue\n",MAX);
            getch();
        }
        else
        {
            break;
        }
    }

    printf("Please input a StudentID and three scores:\n");
    printf("    StudentID  Chinese  Math    English\n");
    for(i=0;i<StuNum;i++)
    {
        printf("No.%d>",i+1);
       scanf("%ld%d%d%d",&StuID[i],&Chinese[i],&Math[i],&English[i]);
        Average[i]=(Chinese[i]+Math[i]+English[i])/3;
    }

    for(AverClass=0,i=0;i<StuNum;i++)
    {
        AverClass+=Average[i];
    }
    AverClass/=StuNum;

    puts("\nStudentNum    Chinese   Math   English  Average");
    puts("-------------------------------------------------");

    for(i=0;i<StuNum;i++)
    {
        printf("%9ld %9d %9d %9d %9.1f\n",StuID[i],Chinese[i],Math[i],English[i],Average[i]);
    }
    puts("-------------------------------------------------");
    printf("Average of the Class =%.2f\n",AverClass);
    puts("Press any key to return");
    getch();
}
搜索更多相关主题的帖子: long continue Chinese between include 
2010-03-20 16:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-300000-1-1.html




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

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