【发布时间】:2013-11-10 10:35:17
【问题描述】:
作为我即将到来的星期二的实验室测试的一部分,我们必须能够做这个问题,否则我们将无法进行真正的考试!
代码如下:
* This program finds the range between highest and lowest value of a 2-D array */
#include <stdio.h>
#define NROW 3
#define NCOL 3
int main(void)
{
/* declare needed variables or constants, e.g. */
int ar[NROW][NCOL];
int number;
int rows, columns;
/* prompt for the user to enter nine positive integers to be stored into the array */
for ( rows = 0 ; rows < 3 ; rows++ )
{
for ( columns = 0 ; columns < 3 ; columns++ )
{
printf("Please enter 9 numbers " );
scanf("%d", &number);ar[NROW][NCOL]
/*store the number temporarily*/
number = dispArray( ar[NROW][NCOL] )
}
}
/* call the disp_arr(...) function */
dispArray()
/* call the highest(...) function */
/* call the lowest(...) function */
/* display the range between highest and lowest number
/* Return to the operating system */
}
void dispArray( a[][] )
int rows, columns, a[][];
for ( rows = 0 ; rows < 3 ; rows++ )
{
for ( columns = 0 ; columns < 3 ; columns ++ )
{
printf( "%d\t", a[][] );
}
printf("\n");
}
return a[][];
/* Write a function where a[][] is the 2-D array
Print the entire array to the screen. */
目前我只需要知道如何将数组打印到屏幕上。我的函数和我在main 中调用它的方式显然是错误的。
我真的不擅长函数,尤其是在传递参数时……我也不知道它是什么。
任何帮助将不胜感激! 谢谢! 山姆
【问题讨论】:
-
先修复编译错误。然后阅读有关数组和指针的更多信息。
-
20 页的《C 编程书》足以解决这个问题,可能还有其他问题。
标签: c function multidimensional-array