fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. typedef struct {
  5. double X;
  6. double Y;
  7. }Point;
  8.  
  9. Point scan_point(void);
  10. double area_of(Point p1, Point p2);
  11. double circumference_of(Point p1, Point p2);
  12.  
  13. int main(void) {
  14. Point p1;
  15. Point p2;
  16.  
  17. p1=scan_point();
  18. p2=scan_point();
  19.  
  20. double area,circumference;
  21.  
  22. area=area_of(p1, p2);
  23. circumference=circumference_of(p1, p2);
  24.  
  25. printf("area=%.2f circumference=%.2f",area,circumference);
  26.  
  27. return 0;
  28. }
  29.  
  30. Point scan_point(void){
  31.  
  32. Point p;
  33.  
  34. scanf("%lf",&p.X);
  35. scanf("%lf",&p.Y);
  36.  
  37. return p;
  38. }
  39.  
  40. double area_of(Point p1, Point p2){
  41. return fabs(p1.X-p2.X)*fabs(p1.Y-p2.Y);
  42. }
  43.  
  44. double circumference_of(Point p1, Point p2){
  45. return fabs(p1.X-p2.X)*2+fabs(p1.Y-p2.Y)*2;
  46. }
  47.  
  48.  
Success #stdin #stdout 0s 5328KB
stdin
3.21
3.65
8.36
9.34
stdout
area=29.30 circumference=21.68