所以问题是开发一个 [5][5] 表,每个表都包含 1-100 的唯一数字(没有重复)
所以这就是我想出的:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int outerLoop;
int innerLoop;
int board[5][5]; /* Array Name And Size*/
/* seeds the random number generator*/
srand(time(NULL));
int number;
number = rand() % 101;
/* Start a loop to generate a random integer between 1 and 100 and
assign it into the array. The loop runs 25 times*/
for ( outerLoop = 0 ; outerLoop <= 25 ; outerLoop++ ) /* loop 25 times*/
{
for ( innerLoop = 0 ; innerLoop <= 4 ; innerLoop++ ) /* <=4 due to 5
columns*/
{
board[outerLoop][innerLoop] = rand() % 100 + 1;
}
printf( "%d \n", board[outerLoop][innerLoop] );
}
所以我几乎被困在这里。我不太确定:
board[outerLoop][innerLoop] = rand() % 100 + 1;
我只是编造的:/有什么想法吗?