按照函数参数值从结构体中获取指定数组值
创始人
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;
}

相关内容

热门资讯

透视课程!pokemmo脚本辅... 透视课程!pokemmo脚本辅助器下载(透视)德州透视插件(辅助)真是是真的有攻略(哔哩哔哩)进入游...
透视总结!sohoo辅助(透视... 透视总结!sohoo辅助(透视)拱趴大菠萝开挂方法(辅助)一直真的是有攻略(哔哩哔哩)1、全新机制【...
透视大纲!hhpoker万能辅... 透视大纲!hhpoker万能辅助器(WePoKer新版本)总是真的是有辅助软件(哔哩哔哩)1、完成h...
透视阶段!pokemmo脚本(... 透视阶段!pokemmo脚本(透视)来玩app 德州 辅助(辅助)原来是有神器(哔哩哔哩)一、来玩a...
透视指南书!wepoker辅助... 透视指南书!wepoker辅助器激活码(HHpoker控制牌)都是存在有辅助脚本(哔哩哔哩)进入游戏...
透视技法!wepoker透视功... 透视技法!wepoker透视功能下载(HHpoker辅助)其实真的是有辅助教程(哔哩哔哩)1、很好的...
透视举措!wepoker轻量版... 透视举措!wepoker轻量版有透视吗(WePoKer最新)原来是真的有辅助app(哔哩哔哩)1、全...
透视模板!pokemmo脚本(... 透视模板!pokemmo脚本(透视)德州真人透视脚本(辅助)真是是有技巧(哔哩哔哩)亲,关键说明,德...
透视妙计!云扑克有透视吗(透视... 您好,pokemmo脚本辅助下载这款游戏可以开挂的,确实是有挂的,需要了解加去威信【13670430...
透视方式!德州来玩辅助器(AA... 透视方式!德州来玩辅助器(AApoker拿好牌)原来是有辅助技巧(哔哩哔哩)1、全新机制【德州来玩辅...