typedef?struct
{
char?name[50];
char?sex;
int?id;
int?score;
}studentInfo_t; /*學生信息的結構體*/
studentInfo_t?studentInfo[50]=
{
{"wang","m",1,81},
{"zhang","f",2,79},
{0} /*初始化50個學生的信息,此處僅舉2例,其余可補充完整*/
};
void?main()
{
int?i;
for(i=0;i<50;i++) /*輪詢50個學生的信息*/
{
if(studentInfo[i].score>=80) /*成績在80分以上時*/
{
/*打印輸出對應的學號、成績*/
printf("student?ID:%d,score:%d\r\n",
studentInfo[i].id,studentInfo[i].score);
}
}
}