1、结构体里没有“英语成绩”
2、main函数第一个for循环中第一个输入cin>>studentS,这个变量名写错了
3、第二个for前面变量声明的时候空格丢个
4、最后输出名字的时候变量名又写错了
#include <iostream>
#include <string>
using namespace std;
struct Student {
string name;
float c_s;
float m_s;
float eh_s;
float avg_s;
};
int main() {
Student students[3];
for (int i=0; i<3; i++) {
cout<< "input the "<< i+1 <<"student name:";
cin >> students[i].name;
cout<< "input Ch score:";
cin >> students[i].c_s;
cout<< "input math score:";
cin >> students[i].m_s;
cout<< "input eh score:";
cin >> students[i].eh_s;
students[i].avg_s = ( students[i].c_s + students[i].m_s + students[i].eh_s )/3.0;
}
int max_index = 0;
for (int i=1; i<3; i++) {
if (students[i].avg_s > students[max_index].avg_s) {
max_index=i;
}
}
cout << "max " << students[max_index].name << endl;
cout << "avg score " << students[max_index].avg_s << endl;
}