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

相关内容

热门资讯

透明安装!禅游指尖四川破解版,... 透明安装!禅游指尖四川破解版,pokermaster破解版(辅助挂)详细开挂辅助软件;打开点击测试直...
透视挂!wepoker智能辅助... 透视挂!wepoker智能辅助插件,xpoker辅助工具(辅助挂)详细开挂辅助器;无需打开直接搜索加...
透明插件!wepoker免费脚... 透明插件!wepoker免费脚本,aapoker怎么设置抽水(辅助挂)详细开挂辅助平台 了解更多开挂...
透视线上!wepokerplu... 透视线上!wepokerplus到底是挂了吗,pokemmo脚本辅助下载(辅助挂)详细开挂辅助下载;...
透明挂透视!乐享麻将连连看辅助... 透明挂透视!乐享麻将连连看辅助,wpk真吗(辅助挂)详细开挂辅助插件您好:乐享麻将连连看辅助这款游戏...
透明挂透视!wepoker黑侠... 您好:这款wepokerplus透视脚本免费游戏是可以开挂的,确实是有挂的,很多玩家在这款wepok...
透视有挂!智星德州插件最新版本... 透视有挂!智星德州插件最新版本更新内容详解,大菠萝免费辅助器(辅助挂)详细开挂辅助插件您好:智星德州...
透视线上!蛮王大厅辅助插件,w... 透视线上!蛮王大厅辅助插件,wpk作弊最怕三个东西(辅助挂)详细开挂辅助插件;无需打开直接搜索打开薇...
透视代打!中指小程序破解头像,... 透视代打!中指小程序破解头像,pokeplus脚本(辅助挂)详细开挂辅助安装;亲,中指小程序破解头像...
透视规律!新永和源代码,wep... 大家好,今天小编来为大家解答wepoker透视脚本免费下载pc这个问题咨询软件客服可以免费测试直接加...