【发布时间】:2015-06-23 23:10:28
【问题描述】:
以下代码中从未输入过函数部分 请帮帮我!
#include<stdio.h>
int findMax(int *a[], int m, int n)//this function is not entering
{
int i,j,k=0;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(k<a[i][j])
k=a[i][j];
printf("hi");//this hi is also not printing
//this hi is just for testing
return k;
}
//如果可能,这个函数会更正它
int main()
{
int m,n,a[50][50],i,j,k=0;
printf("Enter the number of rows in the matrix\n");
scanf("%d",&m);
printf("Enter the number of columns in the matrix\n");
scanf("%d",&n);
printf("Enter the elements in the matrix\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
printf("The matrix is");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d ",a[i][j]);
}
k=findMax((int **)a,m,n);//statements after this is never running but no
//compilation errors
printf("\nThe maximum element in the matrix is %d",k);
return 0;
}
请帮帮我!! 提前谢谢你!
【问题讨论】:
-
如果我把
m和n分别设置为201和403呢? -
你用调试器看看会发生什么吗?
-
@SamiKuhmonen 我已经执行过了,它显示的就像编译时错误
-
@SouravGhosh 为什么有人要求 15*15 你去那里?我只需要一个解决方案!
-
hy it was juz asked for 15*15 y do u go there? i just need a solution for this!... 我只是想提供一些免费的建议来保存您的程序以防错误输入。如果您对接近损坏的代码和just need a solution for this没问题,那么上帝会帮助您!