gpt4 book ai didi

c - 将矩阵线传递给函数 C

转载 作者:行者123 更新时间:2023-11-30 17:03:22 25 4
gpt4 key购买 nike

我有一个矩阵(二维数组),并且想要将某一行的值发送到函数。

例如:

如果我有矩阵players[10][50],那么我怎样才能只传递players[0][0...50]?

最佳答案

尝试使用指针进行类似的操作...

#include <stdio.h>

void printArrayRow(int * row, int rowSize)
{
int i;

for (i=0; i<rowSize; i++)
printf("%d ",row[i]);

printf("\n");
}

int main(int argc, char *argv[]) {

int data[4][4] = {{0,1,2,3},
{1,2,3,4},
{2,3,4,5},
{3,4,5,6}};

printArrayRow(data[1], 4);
}

关于c - 将矩阵线传递给函数 C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36226444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com