主题:一段程序的报警,请教好心人
以下程序完成三门课程的成绩输入,求平均分输出。
编译时没问题,但运行时报警,报警见附件。
请好心人指出原因所在。谢谢!!!
//求三门课程的平均分
#include <iostream.h>
#include<iomanip.h>
#include<string.h>
void get_score(double *,double *,double *);
int subject_number=1;
char *subject;
int main()
{
double a,b,c,d;
while (subject_number<4&&subject_number>0)
{
get_score(&a,&b,&c);
subject_number++;
d=(a+b+c)/3;
cout<<subject<<"平均成绩是"<<d<<endl;
}
return 0;
}
void get_score(double *a,double *b,double *c)
{
switch(subject_number)
{
case 1:
strcpy(subject,"语文");
break;
case 2:
strcpy(subject,"数学");
break;
case 3:
strcpy(subject,"英语");
break;
default:
cout<<"没有该门课";
}
cout<<"请输入"<<subject<<"成绩"<<endl;
cin>>*a>>*b>>*c;
}
编译时没问题,但运行时报警,报警见附件。
请好心人指出原因所在。谢谢!!!
//求三门课程的平均分
#include <iostream.h>
#include<iomanip.h>
#include<string.h>
void get_score(double *,double *,double *);
int subject_number=1;
char *subject;
int main()
{
double a,b,c,d;
while (subject_number<4&&subject_number>0)
{
get_score(&a,&b,&c);
subject_number++;
d=(a+b+c)/3;
cout<<subject<<"平均成绩是"<<d<<endl;
}
return 0;
}
void get_score(double *a,double *b,double *c)
{
switch(subject_number)
{
case 1:
strcpy(subject,"语文");
break;
case 2:
strcpy(subject,"数学");
break;
case 3:
strcpy(subject,"英语");
break;
default:
cout<<"没有该门课";
}
cout<<"请输入"<<subject<<"成绩"<<endl;
cin>>*a>>*b>>*c;
}