Home > Back-end >  C, the main function can't call function
C, the main function can't call function

Time:11-25

Just learning C language, write a program, the main function can't call function, the Max and min useless |? Omega? `) for bosses to help solve, what's wrong with _ (: з) _ thank you
<)Code # include< as follows; Stdio. H>

Void main ()
{
Double Max (double [x]);
Double min (double y []);
Double a, [10].
int i;

Printf (" input 10 Numbers: ");
for(i=0; i<10; I++)
{
Lf the scanf (" % ", & amp; A [I]);
}
Printf (" Max=% g, min=% g \ n ", Max (a [10]), min (a) [10]);
}

Double Max (double x [])
{
Void swap (double, double j);
Double Max;
int i;
For (Max=x [0], I=0; i<9. I++)
{
If (max<[I x + 1])
{
[I swap (Max, x + 1]).
}
}
return max;
}

Double min (double y [])
{
Void swap (double, double j);
Double min;
int i;
For (min=y [0], I=0; i<9. I++)
{
If (min> Y [I + 1])
{
Swap (min, y [I + 1));
}
}
Return min;
}

Void swap (double, double j)
{
Double t;
T=I;
I=j;
J=t;
}

CodePudding user response:

Void swap (double, double j);
This exchange function without statement in each sub function in the
Another simple and maximum minimum whole so complicated by you,
 
Double Max (double x [])
{
Double Max;
int i;
Max=x [0];
For (I=0; i<10; I++)
{
If (maxMax=x [I]
}
return max;
}

This is ok

CodePudding user response:

Ah, I see, thank you |? Omega? `) because here just learn array pointer, just find a sample to try, so chose such a complex way to _ (: з) _
<)After I remove the swap to you so good, can I ask again why not before |? Omega? `) still don't quite understand

CodePudding user response:

The original poster to find problem is good, suddenly exposed the problem, is your swap parameter value, want to use a pointer, passed to address, such ability to modify the parameters

CodePudding user response:

reference poetryTang reply: 3/f
the building looking for good, suddenly exposed the problem, is your swap parameter values, with a pointer, passed to address, such ability to modify the parameters

Oh, I see, thank you, thank you for the help of (? O? O)?