{
Int * p=& amp; A [0], I;
for(i=0; I
If (* pP=& amp; A, [I].
}
Return * p;
}
Int * min (int a [], int n)
{
Int * p=& amp; A [0], I;
for(i=0; I
If (* p> A [I])
P=& amp; A, [I].
}
Return * p;
}
Int ave (int a [], int n)
{
Int I, sum=0;
for(i=0; I
The sum +=a [I];
}
Return the sum/n;
}
#include
Int main ()
{
,2,3,4,5,6,7,8,9,10 int [10] b={1}, n=10, big, small, pingjun;
Big=Max (b [0], n);
Small=min (b [0], n);
Pingjun=ave (b [0], n);
Printf (" % d % d % d ", big, small, pingjun);
return 0;
}
Emmm displayed in the Max and min is a problem with the two function and is the main function of Max and min input has a problem,
CodePudding user response:
You just said there is a problem, do not say what specific phenomenon? Compile or run issue?CodePudding user response:
You define the parameter is an array of addresses, the incoming value isInt * Max (int a [], int n) int a [] to pass a first address ()
Big=Max (b [0], n);
Small=min (b [0], n);
* p=a, is p take a first address, it is not necessary to & a [0]; More easily mistaken
CodePudding user response:
And you have a problem the return value isInt * min (int a [], int n) you define the type of the return value is a pointer, but you return values, have a good look at, suggested that the pointer * has different meanings in different places
CodePudding user response:
//int * Max (int a [], int n)
Int Max (int a [], int n)
{
Int * p=& amp; A [0], I;
for(i=0; I{
If (* pP=& amp; A, [I].
}
Return * p;
}
//int * min (int a [], int n)
Int min (int a [], int n)
{
Int * p=& amp; A [0], I;
for(i=0; I{
If (* p> A [I])
P=& amp; A, [I].
}
Return * p;
}
Int ave (int a [], int n)
{
Int I, sum=0;
for(i=0; I{
The sum +=a [I];
}
Return the sum/n;
}
//# include & lt; stdio.h>
Int main ()
{
,2,3,4,5,6,7,8,9,10 int [10] b={1}, n=10, big, small, pingjun;
//big=Max (b [0], n);
Big=Max (b, n);
//small=min (b [0], n);
Small=min (a, b, n);
//pingjun=ave (b [0], n);
Pingjun=ave (b, n);
Printf (" % d % d % d \ n ", big, small, pingjun);
return 0;
}
For your reference ~
Big=Max (& amp; B [0], n);
Also can such,
CodePudding user response: