不会写这个c语言,翻译时//main那往回不翻译,帮帮忙

不会写这个c语言,翻译时//main那往回不翻译,帮帮忙

问题描述:

Write a function named copy_arr(source, target, length) to copy the contents of an array-of-double to another array.
Write another function named sort(array, length) to sort the array passed by parameter in descending order.(降序排序,从大到小)
Write a main() function that initializes the array-of-double and then call copy_arr() to make the copy, and show all the element-values of the copied array . Then call the sort() function , and show all the element-values of the sorted array.
Using the following main() function for test your functions.

//main(),不要修改
int main(){
double source[5] = {1.1, 2.2, 3.3., 4.4, 5.5};
double target [5];
copy_arr(source, target, 5);
display_array(target, 5);
sort(target, 5);
display_array(source, 5);//for comparing
display_array(target, 5);
}

#include <stdio.h>
void copy_arr(double *source,double *target,int n)
{
      for(int i=0;i<n;i++)
          *(target+i) = *(source+i);
}

void sort(double *arr,int n)
{
      int i,j;
      double d;
      for(i=0;i<n-1;i++)
          for(j=0;j<n-i-1;j++)
          {
                if(arr[j] < arr[j+1])
                {
                      d = arr[j];
                      arr[j]= arr[j+1];
                      arr[j+1] = d;
                }
          }
}

void display_array(double *arr,int n)
{
      for(int i=0;i<n;i++)
          printf("%lf ",arr[i]);
}

int main(){
double source[5] = {1.1, 2.2, 3.3, 4.4, 5.5};
double target [5];
copy_arr(source, target, 5);
display_array(target, 5);
sort(target, 5);
display_array(source, 5);//for comparing
display_array(target, 5);
}



emmm我也看不大懂...