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

相关内容

热门资讯

透视神器"wepok... 1、透视神器"wepoker辅助器怎么弄"详细辅助2025新版总结(确实真的是有挂)。2、wepok...
透视私人局"wepo... 透视私人局"wepoker私人局辅助器怎么用"详细辅助AI教程(果然是真的有挂)这是由厦门游乐互动科...
透视计算"wepok... 1、透视计算"wepoker软件靠谱么"详细辅助第三方教程(固有存在有挂);详细教程。2、wepok...
透视黑科技"wepo... 1、透视黑科技"wepoker破解是真的还是假的"详细辅助教你攻略(原生真的有挂)。2、wepoke...
透视透视"aa po... 透视透视"aa poker透视软件"详细辅助详细教程(一向真的是有挂);大神普及一款德州ai内幕,确...
透视透视"wepok... 这是一款非常优秀的wepokerplus透视脚本免费 ia辅助检测软件,能够让你了解到wepoker...
透视了解"xpoke... 透视了解"xpoker辅助工具"详细辅助安装教程(原生有挂);亲真的是有正版授权,小编(透视辅助软件...
透视线上"约局吧怎么... 透视线上"约局吧怎么看有没有挂"详细辅助透牌教程(竟然有挂);支持多人共享记分板与复盘,通过邀请好友...
透视透视"werpl... 透视透视"werplan脚本"详细辅助解密教程(一贯有挂);大神普及一款德州ai内幕,确定了werp...
透视规律"wepok... 透视规律"wepoker免费透视"详细辅助科技教程(固有真的是有挂)是一款可以让一直输的玩家,快速成...