[练习9-4]定义一个包含5名学生信息的数据结构,并对该数组的所有元素进行初始化。

#include <stdio.h>

struct student{
    int num;
    char name[40];
    int computer, english, math;
};

int main(void){
    int i;
    struct student students[5] = {
        {1,"Bob",66,77,88},
        {2,"Alix",76,77,88},
        {3,"Tom",66,97,58},
        {4,"Mon",66,77,88},
        {5,"Tli",63,87,48},
    };
    
    
    
    for (i = 0; i < 5; i++) {
        printf("%d \t %5s \t \n",students[i].num, students[i].name);
    }
    return 0;
}

 

posted @ 2021-09-19 12:18  就是想学习  阅读(126)  评论(0编辑  收藏  举报