fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void swap(double points[20][2],int i, int j){
  5. double tmp[2];
  6. memcpy(tmp, points+i, sizeof(*points));
  7. memcpy(points+i, points+j, sizeof(*points));
  8. memcpy(points+j, tmp, sizeof(*points));
  9. }
  10.  
  11. int main(void) {
  12. double points[20][2]={{1,2},{2,3},{3,4},{4,5}};
  13. swap(points, 0, 1);
  14. for (int i = 0 ; i != 4 ; i++) {
  15. printf("%f %f\n", points[i][0], points[i][1]);
  16. }
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 4312KB
stdin
Standard input is empty
stdout
2.000000 3.000000
1.000000 2.000000
3.000000 4.000000
4.000000 5.000000