#include
void swap(double fr[], double ar[]);
void copy_arr(double fr[], double er[],int size);
void sorting(double fr[],double ar[],int n);
int main(void)
{
double target[5];
double source[5] = {
1.1,2.2,3.3,4.2,5.2 };
swap(&source[0],&source[1]);//这里要&,要取地址,不然交换完return之后就没了
printf("%lf,%lf,%lf,%lf,%lf\n",source[0],source[1],source[2],source[3],source[4]);
sorting(target,source,5);
printf("%lf,%lf,%lf,%lf,%lf\n",target[0],target[1],target[2],target[3],target[4]);
return 0;
}
void sorting(double tr[],double sr[],int n)
{
int i,k=0;
copy_arr(tr,sr,n);
for(k=0;k void swap(double *fr, double *ar) { void copy_arr(double fr[], double er[],int size) swap(&tr[i],&tr[i+1]);
}
}
return;
}
double i;
if(*fr<*ar)
i = *ar;
*ar = *fr;
*fr= i;
return;
}
{
int i;
for(i = 0; i < size; i++)
fr[i] = er[i];
return;
}你可能感兴趣的:(c语言,开发语言)