编写一个学生信息的结构数组,包含学号,身高,体重
输入1,2,3分别按照学号,身高,体重排序
麻烦帮我看看哪里出错了
#include "stdafx.h"
#include
struct Student
{int num;
float hgt;
float wgt;
};
int main(int argc, char* argv[])
{
struct Student stu[5]={{20801,175,60},{20903,183.2,71.3},{20705,169.1,66.4},
{20841,185.6,78},{20735,192,86.5}};
struct Student temp;
const int n=5;
int x,i,j,k;
cout>x;
switch(x)
{
case 1:
coutstu[k].num)
k=j;
temp=stu[k];stu[k]=stu;stu=temp;
}
for(i=0,istu[k].hgt)
k=j;
temp=stu[k];stu[k]=stu;stu=temp;
}
for(i=0,istu[k].wgt)
k=j;
temp=stu[k];stu[k]=stu;stu=temp;
}
for(i=0,i<n;i++)
cout<<"the order is: "<<stu.num,stu.hgt,stu.wgt<<endl;
break;
}
return 0;
}
|