gpt4 book ai didi

c - b 和 *b 在我的函数的参数列表中工作完全相同。那有什么区别呢?

转载 作者:太空宇宙 更新时间:2023-11-04 01:34:13 25 4
gpt4 key购买 nike

<分区>

我使用 swapCardsRandomly(b) 但是当我尝试 swapCardsRandomly(*b) 程序仍然可以正常工作。

那有什么区别呢?

/*
*shuffles cards randomly
*/
void shuffle( int b[][13] ) {

int counter;
int rand1 = rand() % 4;
int rand2 = rand() % 13;

b[rand1][rand2] = 1;

counter = 2;
while ( counter < 53 )
{
rand1 = rand() % 4;
rand2 = rand() % 13;

while ( b[rand1][rand2] != 0 )
{
rand1 = rand() % 4;
rand2 = rand() % 13;
}

b[rand1][rand2] = counter++;
}
swapCardsRandomly( b );
}

//for better shuffling swap elements randomly
void swapCardsRandomly( int m[][13] ) {

int temp;
int rand1;
int rand2;

for ( i = 0; i < 4; i++ )
{
for ( j = 0; j < 13; j++ )
{
rand1 = rand() % 4;
rand2 = rand() % 13;

temp = m[i][j];
m[i][j] = m[rand1][rand2];
m[rand1][rand2] = temp;

}
}
}

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