jooh123 2016-04-13 08:44 采纳率: 0%
浏览 2175

求大神帮忙解疑/*创建一个结构数组,用于存储多个学生的学号、姓名、成绩。

/*
创建一个结构数组,用于存储多个学生的学号、姓名、成绩。
输出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)

  • 写回答

1条回答 默认 最新

  • qq_25289489 2016-04-21 13:18
    关注

    你的student不是数组啊,怎么会有stu[i]!!!

    评论

报告相同问题?

悬赏问题

  • ¥15 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题