/* 结构体类型与结构体变量的声明格式 */
/* struct [结构体名]
{ 成员类型 成员1
成员类型 成员2
成员类型 成员3
。。。
成员类型 成员n
}[结构体变量名]
*/
#include <iostream>
using namespace std;
struct Student
{
int no;
char name[16];
char sex;
float score;
};
void main()
{
int i,n=0;
float sum=0,average;
struct Student s[5]={
{101,"li ping",'f',50},
{102,"liu hua",'m',78},
{103,"jin shan",'f',90},
{104,"he gang",'m',45},
{105,"yangliu",'f',90}
};
for(i=0;i<5;i++)
{
sum=sum+s[i].score;
if (s[i].score<60)
n++;
}
average=sum/5;
cout<<"这五个学生的平均分为:"<<average<<endl;
cout<<"不及格人数为:"<<n<<endl;
system("pause");
}