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

typedef struct {
    double x;
    double 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 = fabs(p1.x - p2.x);
    double height = fabs(p1.y - p2.y);
    return width * height;
}

double circumference_of(Point p1, Point p2) {
    double width = fabs(p1.x - p2.x);
    double height = fabs(p1.y - p2.y);
    return 2.0 * (width + height);
}

int main(void) {
    printf("左上隅の座標(p1)を入力:\n");
    Point p1 = scan_point();

    printf("\n右下隅の座標(p2)を入力:\n");
    Point p2 = scan_point();

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

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

    return 0;
}
