Problems
Point
Point
The point is given with its x and y coordinates: (x, y).
Two points (a, b), (c, d) and an integer n are given. Add them.
Adding two points means to add the corresponding coordinates: (1, 2) + (3, 4) = (4, 6).
Adding point and a number means to add a number to both point coordinates: (1, 2) + 10 = (11, 12).
Write the code according to the next interface:
class Point // C++
{
private:
int x, y;
public:
Point(int x = 0, int y = 0); // Constructor
void Read(void); // Read vector coordinates
void Print(void); // Print vector coordinates
Point operator +(int v); // Overload operator +: return the sum of point and integer v
Point operator +(Point &p); // Overload operator +: return the sum of two points
int getX(void); // Return x coordinate
int getY(void); // Return y coordinate
void SetX(int x); // Set x coordinate
void SetY(int y); // Set y coordinate
};
class Point // Java
{
private int x, y;
Point(int x, int y); // Constructor
public String toString(); // Return the string with point coordinates
public Point Add(int v); // Add to both point coordinates the value of v, return the point
public Point Add(Point p); // Add point p, return the sum of to points
public int getX(); // Return x coordinate
public int getY(); // Return y coordinate
public void SetX(int x); // Set x coordinate
public void SetY(int y); // Set y coordinate
};
Input
The first line contains the coordinates a and b of the first point. The second line contains the coordinates c and d of the second point. The third line contains an integer n. All values do not exceed 10000 by the absolute value.
Output
Print the sum of two points and a number.
Input example #1
1 2 3 4 10
Output example #1
14 16