Home > Back-end >  Design complete program to achieve the following functions: there are 10 elements to an array {,8,10
Design complete program to achieve the following functions: there are 10 elements to an array {,8,10

Time:09-18

Don't know what is going wrong, application result not to
#include
Void A (int * A, int * p, int j);
A void B (int * and an int * q, int k);
# define N 10
Void main ()
{
Int p, q, j=0, k=0;
,8,10,2 int a [N]={1, 5,0,7,15,4, 5};
A (A, & amp; P, j);
Printf (" maximum array cuhk and subscript: % d % d \ n ", p, j);
B (a, & amp; Q, k);
Cuhk minimum value and its array subscript: printf (" % d % d \ n ", q, k);
}
Void A (int * A, int * p, int j)
{
int i;
j=0;
P=a;
for(i=1; I<10; I++)
{
If (* p<* (a + I))
* p=* (a + I);
J=I - 1;
}
}
A void B (int * and an int * q, int k)
{
int i;
k=0;
Q=a;
for(i=1; I<10; I++)
{
If (* q> * (a + I))
* q=* (a + I);
K=I - 1;
}
}

CodePudding user response:

Your function is defined, so the * p=* (a + I); * p is equivalent to the value transfer, affirmation can not return, it is ok to use pointer to a pointer, and subscript also wrong

#include

Void A (int * A, * * p int, int & amp; J);
A void B (int * and * * q, int int & amp; K);

# define N 10

Void main ()
{
Int * p, * q;
Int j=0, k=0;
,8,10,2 int a [N]={1, 5,0,7,15,4, 5};
A (A, & amp; P, j);
Printf (" maximum array cuhk and subscript: % d % d \ n ", * p, j);
B (a, & amp; Q, k);
Cuhk minimum value and its array subscript: printf (" % d % d \ n ", * q, k);
}
Void A (int * A, * * p int, int & amp; J)
{
int i;
j=0;
* p=a;

for(i=1; I<10; I++)
{
If (* * p<* (a + I))
{
P=* * * (a + I);
J=I;
}
}
}
A void B (int * and * * q, int int & amp; K)
{
int i;
k=0;
* q=a;
for(i=1; I<10; I++)
{
If (* * q> * (a + I))
{
Q=* * * (a + I);
K=I;
}
}
}

CodePudding user response:

Or run out, shows that there is an error

CodePudding user response:

Debugging, breaking point