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

typedef struct {
    double x;
    double y;
} Point;

/* X座標とY座標を入力してPoint型の変数を返す */
Point scan_point(void)
{
    Point p;

    printf("X座標を入力してください: ");
    scanf("%lf", &p.x);

    printf("Y座標を入力してください: ");
    scanf("%lf", &p.y);

    return p;
}

/* 長方形の面積を計算する */
double area_of(Point p1, Point p2)
{
    double width;
    double height;

    width = fabs(p2.x - p1.x);
    height = fabs(p2.y - p1.y);

    return width * height;
}

/* 長方形の周囲の長さを計算する */
double circumference_of(Point p1, Point p2)
{
    double width;
    double height;

    width = fabs(p2.x - p1.x);
    height = fabs(p2.y - p1.y);

    return 2.0 * (width + height);
}

int main(void)
{
    Point p1, p2;
    double area, circumference;

    printf("左上隅の座標を入力します。\n");
    p1 = scan_point();

    printf("\n右下隅の座標を入力します。\n");
    p2 = scan_point();

    area = area_of(p1, p2);
    circumference = circumference_of(p1, p2);

    printf("\n面積 = %.2f\n", area);
    printf("周囲の長さ = %.2f\n", circumference);

    return 0;
}