Point Struct

Lab C Beginner 10 points

Define struct Point { int x; int y; };. Read two points and print the Manhattan distance |x1-x2| + |y1-y2|.

Input

Two lines: x y.

Output

One integer.

Example

Input

0 0
3 4

Output

7
Sample input available Sample output available
Editor
C

Hints

Access fields with the dot: a.x

scanf needs &a.x - the address of the field.

Solution explanation

A struct groups related variables under one name.

Show solution
#include <stdio.h>
#include <stdlib.h>

struct Point {
    int x;
    int y;
};

int main() {
    struct Point a, b;
    scanf("%d %d", &a.x, &a.y);
    scanf("%d %d", &b.x, &b.y);
    printf("%d\n", abs(a.x - b.x) + abs(a.y - b.y));
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD