按照函数参数值从结构体中获取指定数组值
创始人
2024-08-24 04:30:07
0
#include 

// 定义一个结构体
struct student{
    int id;
    int scores[3];
};

// 获取指定数组值的函数
int get_score(struct student stu, int index){
    return stu.scores[index];
}

int main(){
    // 定义一个结构体数组,并初始化
    struct student stu_arr[3] = {{1, {90, 88, 92}}, {2, {87, 94, 89}}, {3, {86, 93, 91}}};

    // 从结构体中获取指定数组值
    int index = 1;
    int score = get_score(stu_arr[1], index);
    printf("学生 [%d] 的第 [%d] 门课的成绩是:%d\n", stu_arr[1].id, index+1, score);

    return 0;
}

相关内容

热门资讯

一分钟辅助!hhpoker有后... 一分钟辅助!hhpoker有后台操作吗,wepoker辅助器有哪些功能,绝活儿教程(今日头条)1、玩...
5分钟辅助!wepoker透视... 5分钟辅助!wepoker透视挂底牌,wpk安卓下载辅助,诀窍教程(有挂辅助)1、wepoker透视...
第1分钟辅助!wepoker辅... 第1分钟辅助!wepoker辅助器安装包,佛手大菠萝辅助,机巧教程(有挂分享)1、每一步都需要思考,...
第七分钟辅助!wepoker好... 第七分钟辅助!wepoker好友助力码,德普之星辅助器app,积累教程(有挂猫腻)1、德普之星辅助器...
第7分钟辅助!wepoker私... 第7分钟辅助!wepoker私人局辅助器怎么用,约局吧开挂神器是真的吗,模板教程(的确有挂)进入游戏...
3分钟辅助!poker wor... 3分钟辅助!poker world辅助器,竞技联盟透视插件,要领教程(有挂详细)1、首先打开竞技联盟...
第一分钟辅助!pokemmo手... 第一分钟辅助!pokemmo手机脚本辅助器,aa poker辅助,手段教程(的确有挂)运pokemm...
1分钟辅助!wepoker钻石... 1分钟辅助!wepoker钻石怎么看底牌,hhpoker脚本下载,教材教程(有挂解惑)1、上手简单,...
第4分钟辅助!约局吧app有挂... 第4分钟辅助!约局吧app有挂吗,hhpoker作弊码怎么用,方案教程(有挂方针)1、首先打开hhp...
第5分钟辅助!德普之星怎么设置... 第5分钟辅助!德普之星怎么设置埋牌,拱趴大菠萝万能挂图解,积累教程(有挂工具)1、许多玩家不知道德普...