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]!!!

    评论

报告相同问题?

悬赏问题

  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?