如何在C语言中使用scanf进行用户输入时,用for循环打印名为grid[][]的2D数组?
假设用户输入3 5,则输出为:
.....
.....
.....
这是我迄今为止编写的代码(我是新手):
#include <stdio.h>
#define MAX 10
int main()
{
int grid[MAX][MAX];
int row, col;
int i,j;
printf("Please enter your grid size: ");
scanf("%d %d", &row, &col);
for (i=0; i<MAX; i++)
for //i gave up here
}
这只是我任务的一小部分:
Enter number of rows and columns followed by list of words (hit enter twice to end list): 10 15
quick
brown
fox
jumped
over
lazy
dog
00 . . . . . . . . . . . . . . .
01 . . . . . . . . . . . . . . .
02 . . . . . . . . . . . . . . .
03 . . . . . . . . . . . . . . .
04 . . . . . . . . . . . . . . .
05 . . . . . . . . . . . . . . .
06 . . . . . . . . . . . . . . .
07 . . . . . . . . . . . . . . .
08 . . . . . . . . . . . . . . .
09 . . . . . . . . . . . . . . .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0. quick
1. brown
2. fox
3. jumped
4. over
5. lazy
6. dog
代码中允许并应包含的函数:字符串函数 - strlen()、strcpy()、strcat()、strchr()、strcmp()、strstr()
必须使用二维数组
必须使用fgets获取单词。输出必须与确切格式匹配。