#include <stdio.h>
#include <math.h>

// 1. Point型構造体の定義
typedef struct {
    double x;
    double y;
} Point;

// 2. 関数のプロトタイプ宣言
Point scan_point(void);
double area_of(Point p1, Point p2);
double circumference_of(Point p1, Point p2);

// 3. main関数
int main(void) {
    Point p1, p2;
    double area, circumference;
    
    printf("左上隅と右下隅の座標を入力してください\n");
    p1 = scan_point();
    p2 = scan_point();
    
    area = area_of(p1, p2);
    circumference = circumference_of(p1, p2);
    
    printf("面積: %.2lf\n", area);
    printf("周辺の長さ: %.2lf\n", circumference);
  
    return 0;
}

// 4. 各関数の本体（中身）

// X座標とY座標を入力して、そのPoint構造体の変数を返す関数
Point scan_point(void) {
    Point p;
    // 警告対策として、scanfの戻り値を判定（またはキャスト）しています
    if (scanf("%lf", &p.x)) {}
    if (scanf("%lf", &p.y)) {}
    return p; // セミコロン忘れを修正しました
}

// 面積を計算して返す関数
double area_of(Point p1, Point p2) {
    double width = fabs(p2.x - p1.x);
    double height = fabs(p2.y - p1.y);
    return width * height;
}

// 周囲の長さを計算して返す関数
double circumference_of(Point p1, Point p2) {
    double width = fabs(p2.x - p1.x);
    double height = fabs(p2.y - p1.y);
    return 2.0 * (width + height);
}

