按照函数参数值从结构体中获取指定数组值
创始人
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辅助怎么用,hhpoker有后台操作吗,安装教程(有挂技巧)1、点击下载安装...
玩家必看教程!竞技联盟破解版最... 玩家必看教程!竞技联盟破解版最新版,云扑克有透视吗,技巧教程(有挂辅助)这是由厦门游乐互动科技有限公...
信息共享!wepoker怎么设... 1、信息共享!wepoker怎么设置房间,wepoker辅助真的假的,揭秘教程(有挂攻略);详细教程...
教程辅助!hhpoker是正规... 教程辅助!hhpoker是正规的吗,约局吧怎么看有没有挂,技巧教程(有挂透明);实战中需综合运用上述...
一分钟快速了解!哈糖大菠萝有挂... 《一分钟快速了解!哈糖大菠萝有挂吗5个常用方法,agpoker辅助,2025版教程(有挂技巧)》 哈...
玩家攻略推荐!智星德州有脚本吗... 玩家攻略推荐!智星德州有脚本吗,wepoker透视脚本安卓,技巧教程(有挂软件);实战中需综合运用上...
终于知道!werplan外挂,... 终于知道!werplan外挂,wepoker可以透视码,wepoke教程(有挂技巧)1、不需要AI权...
程序员教你!pokemmo脚本... 程序员教你!pokemmo脚本辅助器,德州局透视,wpk教程(有挂技巧)这是由厦门游乐互动科技有限公...
新手必备!德普之星辅助工具如何... 新手必备!德普之星辅助工具如何打开,wepoker提高好牌率,技巧教程(有挂技巧);亲真的是有正版授...
必看攻略!pokemmo手机脚... 《必看攻略!pokemmo手机脚本,wepoker怎么拿到好牌,力荐教程(有挂技巧)》 wepoke...