Editor shows 0 warning0error, but in the end but cannot run shows that there is a problem,,, where is make wrong?
# include
Void inp (int * p);
Void change (int * p);
Void oup (int * p);
The main ()
{int a [10], * p=a;
Inp (p);
Change (p);
Oup (p);
}
Void inp (int * p)
{int I;
Printf (" do input 10 integers: ");
for(i=0; I<10; I++)
The scanf (" % d ", * (p + I));
}
Void change (int * p)
Min {int temp, * and * Max, n.
Min=p;
For (n=1; N<10; N++)
{if (* min> * (p + n))
Min=p + n.
}
Temp=* p;
P=min;
* min=temp;
Max=p;
For (n=1; N<10; N++)
{if (* max<* (p + n))
Max=p + n.
}
Temp=* (p + 9);
* (p + 9)=* Max;
* Max=temp;
}
Void oup (int * p)
{int I;
for(i=0; I<10; I++)
Printf (" % d ", * (p + I));
}
CodePudding user response:
Using pointer must finish? If not complete, with an array you this pointer exchange there should be a mistakeCodePudding user response:
# include
Void inp (int * p);
Void change (int * p);
Void oup (int * p);
Int main ()
{
Int a [10], * p=a;
Inp (p);
Change (p);
Oup (p);
return 0;
}
Void inp (int * p)
{
int i;
Printf (" do input 10 integers: \ n ");
for (i=0; I<10; I++)
The scanf (" % d ", (p + I));//-- -- -- -- -- -- -- -- -- -- - * (p + I) to (p + I) -- -- -- -- -- -- -- -- -- -- -- -- --
}
Void change (int * p)
{
Int temp, min, Max, n;
Min=p;
For (n=1; N<10; N++)
{
If (* min> * (p + n))
Min=p + n.
}
Temp=* p;
* p=* min;//-- -- -- -- -- -- -- -- -- p=min min to * p=* -- -- -- -- -- -- -- -- --
* min=temp;
Max=p;
For (n=1; N<10; N++)
{
If (* max<* (p + n))
Max=p + n.
}
Temp=* (p + 9);
* (p + 9)=* Max;
* Max=temp;
}
Void oup (int * p)
{
int i;
for (i=0; I<10; I++)
Printf (" % d ", * (p + I));//-- -- -- -- -- -- -- -- -- -- add a space after % d -- -- -- -- -- -- -- -- -- -- -- --
}
C + + environment debugging VS2015
CodePudding user response:
Ok!Can you bother to ask you why not add when p=a (array) *, are not added when the scanf *, * p=* min, however, when the printf to add *,,,
CodePudding user response:
The