看不太清楚,最好用电脑把代码发上来
你的结构体定义声明有问题:
把结构体改为
struct student
{
float No;
char Name[100];//改成字符型数组
int b[3];
int Sum;
}
按你的思路修改了一下,对比一下错误原因吧!
struct student
{
char no[9];
char name[20];
float h[4];
float sum;
};
void input(struct student *a)
{
cout << "请输入学生学号和姓名" << endl;
cin >> a->no >> a->name;
cout << "请依次输入学生的数学 物理 数据结构成绩" << endl;
cin >> a->h[0] >> a->h[1]>> a->h[2];
}
void sumscore(struct student *a)
{
a->sum = a->h[0] + a->h[1] + a->h[2];
}
void show(const struct student *a)
{
cout << "该学生成绩为:" << a->h[0]<< “ ”<< a->h[1] << “ ”<< a->h[2]<
}
int main()
{
struct student a;
input(&a);
sumscore(&a);
show(&a);
return 0;
}