Struct Basics

Lab C++ Beginner 10 points

Define struct Point { int x, y; };. Read two points and print the squared distance between them.

Input

Two lines: x y.

Output

One integer.

Example

Input

0 0
3 4

Output

25
Sample input available Sample output available
Editor
C++

Hints

Access members with the dot operator.

Solution explanation

In C++, a struct is a class whose members are public by default.

Show solution
#include <iostream>
using namespace std;

struct Point {
    int x, y;
};

int main() {
    Point a, b;
    cin >> a.x >> a.y >> b.x >> b.y;
    int dx = a.x - b.x, dy = a.y - b.y;
    cout << dx * dx + dy * dy << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD