【发布时间】:2014-04-03 23:34:29
【问题描述】:
我正在制作一个单词搜索程序,并且处于起步阶段。在用户输入进入单词搜索的单词之前,我试图让用户输入大小为“+”的网格。当我运行程序时,它只打印出一个'+'。为什么它只打印一个值以及如何调整我的代码以使每个值都表示为“+”?我是一名编程初学者,所以任何建议都会有所帮助..谢谢。
#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");
}
}
【问题讨论】: