希望大家帮我看看这个程序、看他错在哪儿了。谢谢,,
# include <iostream>using namespace std;
struct xs
{
int 学号;
char 姓名[5];
char 性别;
int 成绩[3];
int 总成绩;
};
const int n=3;
int main()
{
void input(struct xs *s,int n);
void output(struct xs *s,int n);
void px(struct xs *s);
struct xs xsb[3];
//cout<<"姓名"<<" "<<"学号"<<" "<<"性别"<<" "<<"成绩1"<<" "<<"成绩2"<<" "<<"成绩3"<<" "<<"总成绩"<<endl;
input(xsb,3);
cout<<"姓名"<<'\t'<<"学号"<<'\t'<<"性别"<<'\t'<<"成绩1"<<'\t'<<"成绩2"<<'\t'<<"成绩3"<<'\t'<<"总成绩"<<endl;
px(xsb);
output(xsb,3);
system("pause");
return 0;
}
void input(struct xs *s,int n)
{
for(int i=0;i<n;i++)
{
cout<<"姓名:";
cin>>s->姓名;
cout<<"学号:";
cin>>s->学号;
cout<<"性别:";
cin>>s->性别;
cout<<"成绩1;";
cin>>s->成绩[0];
cout<<"成绩2;";
cin>>s->成绩[1];
cout<<"成绩3;";
cin>>s->成绩[2];
for(int m=0;m<3;m++)
{
s->总成绩=s->成绩[0]+s->成绩[1]+s->成绩[2];
}
}
}
void px(struct xs *s)
{
for(int y=0;y<n;y++)
{
struct xs t;
struct xs *s;
int r,c;
for(r=0;r<n;r++)
{
for(c=0;c<n-1-r;c++)
if(s->总成绩>(s+1)->总成绩)
{
t=s[c];
s[c]=s[c+1];
s[c+1]=t;
}
s++;
}
}
}void output(struct xs *s,int n)
{
for(int i=0;i<n;i++)
{
cout<<s->姓名<<'\t'<<s->学号<<'\t'<<s->性别<<'\t'<<s->成绩[0]<<'\t'<<s->成绩[1]<<'\t'<<s->成绩[2]<<'\t'<<s->总成绩<<endl;
s++;
}
}