CodePudding user response:
My program is as follows# include
Int main ()
{
Void input (int a []);
Int a, [10].
Void f (int a []);
Void the output (int a []);
Input (a);
F (a);
The output (a);
return 0;
}
Void input (int a [])
{
int i=0;
Printf (" do input 10 Numbers: \ n ");
for (i=0; i<10; I++)
{
Printf (" % d number is: ", I + 1);
The scanf (" % d ", & amp; A [I]);
}
}
Void f (int a [])
{
Int t;
Int min=a [0], Max=a, [0].
P1, int * * p2.
int i=0;
For (I=0; i <10; I++)
{
If (a [I]
Min=a, [I].
P1=& amp; A, [I].
}
If (a [I] & gt; Max)
{
max=a[i];
The p2=& amp; A, [I].
}
}
T=a, [0].
A [0]=* p1;
* p=t;
T=a, [9].
A [9]=* (p2);
* the p2=t;
}
Void the output (int a [])
{
Int I=0;
For (I=0; i <10; I++)
{
Printf (" % 3 d ", a [I]);
}
printf("\n");
Printf (" the smallest number is: % 3 d, the largest number is: % 3 d \ n ", a [0], a [9]);
}
CodePudding user response:
Your handler is too messy, for reference based on your code changes,
# include
Void input (int a []);
Void f (int a []);
Void the output (int a []);
Int main ()
{
Int a, [10].
Input (a);
F (a);
The output (a);
return 0;
}
Void input (int a [])
{
int i=0;
Printf (" do input 10 Numbers: \ n ");
for (i=0; i<10; I++)
{
Printf (" % d number is: ", I + 1);
The scanf (" % d ", & amp; A [I]);
}
}
Void f (int a [])
{
Int t=0, minindex=0, maxindex=0;
Int min=a [0], Max=a, [0].
int i=0;
For (I=0; i <10; I++)
{
If (a [I]{
Min=a, [I].
Minindex=I;
}
If (a [I] & gt; Max)
{
max=a[i];
Maxindex=I;
}
}
If (minindex!=0)
{
T=a, [0].
A [0]=a, [minindex].
A [minindex]=t;
}
If (maxindex!=9)
{
T=a, [9].
A [9]=a, [maxindex].
A [maxindex]=t;
}
}
Void the output (int a [])
{
int i=0;
For (I=0; i <10; I++)
{
Printf (" % 3 d ", a [I]);
}
printf("\n");
Printf (" the smallest number is: % 3 d, the largest number is: % 3 d \ n ", a [0], a [9]);
}
CodePudding user response:
I used your program, very grateful to the , but I still want to ask where my program is wrong,