#include <iostream>
using namespace std;
#include <string>
struct STUDENT
{
string No[5];
string Name[20];
int Chinese;
int Math;
int English;
int SUM = Math + Chinese + English;
int Average = SUM / 3;
};
int Input(int n, struct STUDENT s[])
{
cout << "依次输入学生的学号,姓名,语文,数学,英语成绩" << endl;
cin >> n;
if (n <= 5)
{
for (int i = 0; i < n; i++)
{
cin << s[i].No
<< s[i].Name
<< s[i].Chinese
<< s[i].Math
<< s[i].English
<< endl;
}
}
}
int main()
{
struct STUDENT s[5];
return 0;
}
提问编辑的时候,能把代码放入代码块中吗?
s[i].No 的类型是什么?
是string No[5];
,而不是string,很显然,cin << 并不识别string [5]。
改正:要么用string No, 要么用char No[5]。Name成员,类似。