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

相关内容

热门资讯

透视教学!wepoker辅助工... 透视教学!wepoker辅助工具,约局吧app有挂吗,AA德州教程(有挂教程)该软件可以轻松地帮助玩...
透视ai"wpk透视... 透视ai"wpk透视辅助方法"详细辅助第三方教程(一直输的号能继续打软件)1、许多玩家不知道wpk透...
透视辅助!红龙poker透视工... 透视辅助!红龙poker透视工具,德普软件,解密教程(有挂辅助)1、点击下载安装,红龙poker透视...
透视美元局"wepo... 透视美元局"wepoker破解游戏盒子"详细辅助新版2025教程(透视苹果系统透明)是一款可以让一直...
透视黑科技!aapoker可以... 透视黑科技!aapoker可以开挂吗,aapoker辅助怎么用,切实教程(有挂解密)1、该软件可以轻...
透视免费"wepok... 透视免费"wepoker私人局透视教程"详细辅助辅助教程(万能挂辅助);wepoker私人局透视教程...
辅助透视"wepok... 辅助透视"wepoker俱乐部辅助"详细辅助2025新版教程(透视脚本视频方法);1.wepoker...
透视总结"wpk辅助... 透视总结"wpk辅助"详细辅助可靠教程(有插件教程);大神普及一款德州ai内幕,确定了wpk辅助真的...
透视总结"wepok... 透视总结"wepoker免费脚本咨询"详细辅助存在挂教程(脚本下载技巧);wepoker免费脚本咨询...
透视辅助"cloud... 透视辅助"cloudpoker外挂"详细辅助透明教程(透视脚本网页技巧);《WPK辅助透视》‌:支持...