main(){intjin();intyuan();inta[5],i;for(i=0;i<5;++){printf(“請輸入第%d個數:”);scanf("%d",a+i);}printf("最近的數是%d。",jin(a,5));printf("最遠的數是%d。",yuan(a,5));}intjin(int*x,intn){inti,sum=0,m=0;floataver;for(i=0;i<n;i++)sum+=*(x+i);av=1.0*sum/n;for(i=1;i<n;i++)if(fabs(x[i]-av)<fabs(x[m]-av))m=i;return*(a+m);}intyuan(int*x,intn){inti,sum=0,m=0;floataver;for(i=0;i<n;i++)sum+=*(x+i);av=1.0*sum/n;for(i=1;i<n;i++)if(fabs(x[i]-av)>fabs(x[m]-av))m=i;return*(a+m);}
main(){intjin();intyuan();inta[5],i;for(i=0;i<5;++){printf(“請輸入第%d個數:”);scanf("%d",a+i);}printf("最近的數是%d。",jin(a,5));printf("最遠的數是%d。",yuan(a,5));}intjin(int*x,intn){inti,sum=0,m=0;floataver;for(i=0;i<n;i++)sum+=*(x+i);av=1.0*sum/n;for(i=1;i<n;i++)if(fabs(x[i]-av)<fabs(x[m]-av))m=i;return*(a+m);}intyuan(int*x,intn){inti,sum=0,m=0;floataver;for(i=0;i<n;i++)sum+=*(x+i);av=1.0*sum/n;for(i=1;i<n;i++)if(fabs(x[i]-av)>fabs(x[m]-av))m=i;return*(a+m);}