我正在制作一个词搜索程序,并在开始的步骤。我想在用户输入进入单词搜索的单词之前使用户输入的大小格子为'+'。当我运行程序时,它只打印出一个'+'。为什么它只打印一个值,如何调整我的代码以使每个值都表示为'+'?我是一名编程初学者,所以任何建议都会有帮助。谢谢。为什么我的二维数组只打印出一个值?
#include<stdio.h>
void printmatrix(char matrix[][20],int);
int main(void)
{
char matrix[20][20]= {{'+'}};
int x=1;
printf("How large would you like the puzzle to be (between 10 and 20):\n");
scanf("%d",&x);
printmatrix(matrix,x);
return 0;
}
/********************************************
Function Name: Printmatrix...this function prints out an empty matrix of the grid size the user asked for
Inputs: Variables x and y...the row and column variables the user inputted
Outputs: Empty matrix filled with '+' thats the size the user asked for
********************************************/
void printmatrix(char matrix[][20],int x)
{
int i,j;
printf("Empty Puzzle:\n");
for (i=0;i<x;i++)
{
for (j=0;j<x;j++)
{
printf("%c", matrix[i][j]);
}
printf("\n");
}
}
我以前做过这个,但在后面的程序步骤中,我必须使用这个矩阵中的特定值插入单词,如果这是有道理的 – user3376431