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

相关内容

热门资讯

透视插件!aapoker透视插... 透视插件!aapoker透视插件(透视)辅助插件工具(总是存在有挂)1.aapoker透视插件 ai...
透视插件!aapoker辅助软... 透视插件!aapoker辅助软件合法吗(透视)透视脚本(其实有挂);1、aapoker辅助软件合法吗...
透视软件!aapoker能控制... 透视软件!aapoker能控制牌吗(透视)透视插件(一贯真的是有挂);1、aapoker能控制牌吗a...
透视攻略!aapoker透视插... 透视攻略!aapoker透视插件(透视)透视方法(原来真的是有挂);该软件可以轻松地帮助玩家将aap...
透视模拟器!aapoker插件... 透视模拟器!aapoker插件(透视)插件(原来真的是有挂)1、aapoker插件ai辅助优化,aa...
透视实锤!aapoker发牌逻... 透视实锤!aapoker发牌逻辑(透视)透视脚本下载(果然有挂)1、aapoker发牌逻辑系统规律教...
透视讲解!aapoker脚本(... 透视讲解!aapoker脚本(透视)插件下载(真是是有挂)1、aapoker脚本系统规律教程、aap...
透视辅助!aapoker透视插... 透视辅助!aapoker透视插件(透视)辅助(果然有挂)1、aapoker透视插件机器人多个强度级别...
透视讲解!aapoker怎么开... 透视讲解!aapoker怎么开辅助器(透视)透视方法(都是真的有挂)1、全新机制【aapoker怎么...
透视插件!aapoker辅助插... 透视插件!aapoker辅助插件工具(透视)透视软件(都是有挂)1、aapoker辅助插件工具ai辅...