#include "stdio.h"
#include "ctype.h"
#include "stdlib.h"
#define CLASSES 3
#define GRADES 30
int grade[CLASSES][GRADES];
void enterGrades(void);
int getGrade(int num);
void dispGrades(int g[][GRADES]);
int main()
{
char ch,str[80];
for( ; ; )
{
do
{
printf("(E)nter grades\n");
printf("(R)eport grades\n");
printf("(Q)uit\n");
gets(str);
ch = toupper(*str);
}
while(ch!='E'&& ch!='R'&& ch!='Q');
switch(ch)
{
case'E':
enterGrades();
break;
case'R':
dispGrades(grade);
break;
case'Q':
return 0;
}
}
system("pause");
}
//Enter the student's grades.
void enterGrades(void)
{
int t,i;
for(t=0;t<CLASSES;t++)
{
printf("Class#%d:\n",t+1);
for(i=0;i<GRADES;i++)
grade[t][i]=getGrade(i);
}
}
//Read a grade.
int getGrade(int num)
{
char s[80];
printf("enter grade for student#%d:",num+1);
gets(s);
return (atoi(s));
}
//Display grades.
void disGrades(int g[][GRADES])
{
int t,i;
for(t=0;t<CLASSES;t++)
{
printf("Class#%d:\n",t+1);
for(i=0;i<GRADES;i++)
printf("student#%d is %d\n",i+1,g[t][i]);
}
}
这个关于二维阵列.存放各班学生的分数.
请问高手们.哪里出问题了.谢谢.