其他分享
首页 > 其他分享> > C语言结构体初始化例子

C语言结构体初始化例子

作者:互联网

#include <stdio.h>
main()
{
    struct student{
        char no[6];
        char name[8];
        int score;
    };
    struct student ab[10]={
        {
            "2020001","张三1",156 
        },{
            "2020002","张三2",157 
        },{
            "2020003","张三3",158 
        },{
            "2020004","张三4",159 
        },{
            "2020005","张三5",160 
        },{
            "2020006","张三6",161 
        },{
            "2020007","张三7",134 
        },{
            "2020008","张三8",126 
        },{
            "2020009","张三9",186 
        },{
            "2020010","张三10",156 
        }
    };
    struct student stmax,stmin;
    int max,min,a;
    stmax=stmin=ab[0];
    for(a=1;a<=9;a++)
    if (ab[a].score>stmax.score) stmax=ab[a];
    if (ab[a].score<stmin.score) stin=ab[a];
    printf("最高分%d")
    getchar();
 }

 

标签:stmax,初始化,ab,struct,张三,C语言,例子,student,score
来源: https://www.cnblogs.com/xkdn/p/16668440.html