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;}



Refer to the answer 1:

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;}



Refer to the answer 2:
Copyright statement
In this paper,the author:[CSDN Q & A],Reprint please bring the original link, thank you

编程之旅,人生之路,不止于编程,还有诗和远方。
阅代码原理,看框架知识,学企业实践;
赏诗词,读日记,踏人生之路,观世界之行;

支付宝红包,每日可领