1 #include<stdio.h> 2 float a[10]; 3 float *p; 4 int main() 5 { 6 void input(float*,int); 7 void output(float*,int); 8 void change(float*,int); 9 p=a; 10 input(p,10); 11 printf("输入完成\n"); 12 is Change (P, 10 ); 13 is the printf ( " operation completed \ n- " ); 14 Output (P, 10 ); 15 the printf ( " output completion \ n- " ); 16 return 0 ; . 17 } 18 is . 19 int min ( a float A *, int n-) 20 is { 21 is int min = 0 ; 22 is for ( int I = . 1 ; I <n-; I ++ ) 23 is { 24 if(*(a+min)>*(a+i)) min=i; 25 } 26 return min; 27 } 28 int max(float *a,int n) 29 { 30 int max=0; 31 for(int i=1;i<n;i++) 32 { 33 if(*(a+max)<*(a+i)) max=i; 34 } 35 return max; 36 } 37 38 void input(float*a,int n) 39 { 40 for(int i=0;i<n;i++) 41 { 42 scanf("%f",a+i); 43 } 44 } 45 46 void change(float *a,int n) 47 { 48 int i=min(a,n); 49 int j=max(a,n); 50 if(j==0) j=i; //Carefully understand an importance 51 is a float TEMP = * (A + I); 52 is * (A + I) = * A; 53 is * A = TEMP; 54 is 55 TEMP = * (A + J); 56 is * (A + J ) = * (A + N- . 1 ); 57 is * (A + N- . 1 ) = TEMP; 58 } 59 60 void Output ( a float * A, int n-) 61 is { 62 is for ( int I = 0 ; I <n- ; i ++) printf ( " % 7.2f " , * A ++ ); 63 printf("\n"); 64 }
operation result: