Error message here!

Hide Error message here!

Error message here!

Hide Error message here!

Error message here!

Close

# There are five students, and the data of each student includes student number, name and three course scores. Input the data of five students from the keyboard, and it is required to calculate and output: (1) the total scores of three courses of each stude

CSDN Q & A 2022-01-15 04:45:16 阅读数:7 评论数:0 点赞数:0 收藏数:0

You can't enter data at all . It's all running behind 0 Display of .

#include<iostream>using namespace std;#define STUDENT struct studentSTUDENT{ int num; char name[20]; float score1; float score2; float score3;};STUDENT student[5];int i;void main(){ for(i=0;i<5;i++) cin>>student[i].num; cin>>student[i].name; cin>>student[i].score1; cin>>student[i].score2; cin>>student[i].score3; cout<<endl; float x,y,a,b; for(i=0;i<5;i++) { x=student[i].score1+student[i].score2+student[i].score3 ; cout<<" The sum of the "<<x<<endl; } y=(student[0].score1+student[1].score1+student[2].score1+student[3].score1+student[4].score1)/5; a=(student[0].score2+student[1].score2+student[2].score2+student[3].score2+student[4].score2)/5; b=(student[0].score3+student[1].score3+student[2].score3+student[3].score3+student[4].score3)/5; cout<<" Average grade in the first course "<<y<<endl; cout<<" The average grade of the second course "<<a<<endl; cout<<" Average grade in the first course "<<b<<endl;}

16 Yes for Cycle you have to add {} ah

for(i=0;i<5;i++){ cin>>student[i].num; cin>>student[i].name; cin>>student[i].score1; cin>>student[i].score2; cin>>student[i].score3;}