[問題] 如何解決副程式的值傳不回來問題
大家好,
請問一下關於副程式的問題,
我寫了一個取最大值的副程式但最後回傳不回來,
請大大幫我看一下問題在哪
謝謝
#include <stdio.h>
#include <stdlib.h>
#define NNx2 5
#define NNy2 5
// ___________ Max ___________ //
void maxmax( double *I1, double temp2 )
{
for ( int i = 0; i < NNx2*NNx2; i++ )
{
if ( I1[i] > temp2 )
{
temp2 = I1[i];
printf("maxmax temp =%f \n", temp2);
}
}
}
int main( void )
{
char filename_I1[] = "a.txt";
double *I1,temp2 = 0;
FILE *fp1;
I1 = (double*) malloc( (NNx2)*(NNy2)*sizeof(double) );
fp1 = fopen( filename_I1, "r" );
for (int i = 0; i < NNx2*NNy2; i++) { fscanf( fp1,"%lf", &I1[ i ] ); }
fclose( fp1 );
printf("\n");
maxmax( I1, temp2 );
printf("maxima=%f\n", temp2);
system("pause");
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.112.230.1
→
05/05 13:02, , 1F
05/05 13:02, 1F
→
05/05 13:03, , 2F
05/05 13:03, 2F
→
05/05 13:03, , 3F
05/05 13:03, 3F
→
05/05 13:09, , 4F
05/05 13:09, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章