/*
创建一个结构数组,用于存储多个学生的学号、姓名、成绩。
输出1:最高分学生的学号、姓名。
输入2:所有学生的平均分
*/
#include
using namespace std;
struct student
{
char num [40];
char name [40];
float score[40];
float ave;
};
student stu;
int main()
{
//定义变量
int i,maxi,n,temp;
float sum,max,average;
//输入数据
cout<<"please input the number of student:";
cin>>n;
for(i=1;i
{
cout
cin>>stu.num>>endl;
cout<<"请输入第"<
cin>>stu.name>>endl;
cout<<"请输入第"<
cin>>stu.score>>endl;
}
//数据处理
average =0;
sum=0;
maxi=0;
sum=0;
for(i=0;i
{
sum+=stu[i].score;
if(stu[i].score>stu[i+1].score)
{
temp=stu[i].score;
stu[i].score= stu[i+1].score
stu[i+1].score=temp
}
}
average=sum/n;
//数据输出
cout<<"NO. name score\n";
for (i=0;i<n;i++)
{
cout<<setw(3)<<stu[i].num<<stu[i].name<<stu[i].score
<<stu[i+1].score;
}
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(31) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(33) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'float [40]' (or there is no acceptable conversion)
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(42) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(42) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(43) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(43) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(43) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(43) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(45) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(45) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(46) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(46) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(46) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(47) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(47) : error C2146: syntax error : missing ';' before identifier 'stu'
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(47) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(47) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(48) : error C2143: syntax error : missing ';' before '}'
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(59) : error C2065: 'setw' : undeclared identifier
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(59) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(59) : error C2228: left of '.num' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(59) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(59) : error C2228: left of '.name' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(59) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(60) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(60) : error C2676: binary '[' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(60) : error C2228: left of '.score' must have class/struct/union type
C:\Users\user\Desktop\新建文件夹\Lab4_3.cpp(63) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
Lab4_3.exe - 1 error(s), 0 warning(s)