#include <iostream>
using namespace std;
struct stu{
long no;
char name[9];
int score1[5];
int score2[5];
int score3[5];
int score4[5];
int score5[5];
float ave;
};
stu student[5];
void main()
{
cout<<"请输入各学生的信息"<<endl;
long no[5];
char name[5];
int score1[5];
int score2[5];
int score3[5];
int score4[5];
int score5[5];
float ave[5];
for(int i=0;i<5;i++)
{ int sum;
cin>>no[i]>>name[i]>>score1[i]>>score2[i]>>score3[i]>>score4[i]>>score5[i];
sum=score1[i]+score2[i]+score3[i]+score4[i]+score5[i];
ave[i]=sum/5;
}
for(int a=0;a<5;a++)
{
stu temp;
for(int b=0;b<5;b++)
{
if(student[b].ave>student[b+1].ave)
{
temp=student[b];
student[b]=student[b+1];
student[b+1]=temp;
}
}
for(int k=0;k<5;k++)
{
cout<<student[k].no<<" "<<student[k].name<<" "<<student[k].ave<<endl;
}
}
}
请问我哪里错了,为什么输入时只能输入一个学生的信息?
/*long no;
char name[5];
int score1;
int score2;
int score3;
int score4;
int score5;
float ave[5];*/
这个是用的指针吗?不懂。
不是指针,这些是注释了的,没用的。/*.......*/中间的就是表示注释,和//差不多。已经在结构体中定义这些就不须在定义了