结构体数组例题1
学生成绩表xscj
#include<iostream>
using namespace std;
int main()
{
struct xscj
{
char xh[100];
float cj[2];
float av;
};
struct xscj xs[4]={{"01",70,80},{"02",78,67},{"03",56,78},{"04",90,80}};
int i;
for(i=0;i<4;i++)
{
xs[i].av=(xs[i].cj[0]+xs[i].cj[1])/2.0;
cout<<xs[i].xh<<'\t'<<xs[i].cj[0]<<'\t'<<xs[i].cj[1]<<'\t'<<xs[i].av<<endl;
}
return 0;
}
网友评论