ExSeed books are very popular for school kids. ExSeed has now come out with an innovative idea of giving dynamic online practice quizzes.
Can you help them in solving one of their mathematical problems?
Given the coordinates of the lower left corner of the rectangle (x,y) and the length and breadth of the rectangle, find the coordinates of the 4 vertices of the rectangle.
Assume that the length and breadth of the rectangle are always even.
Input and Output Format:
Input consists of 4 integers.
The 1st integer corresponds to the x-coordinate of the left corner of the rectangle.
The 2nd integer corresponds to the y-coordinate of the left corner of the rectangle.
The 3rd integer corresponds to the length of the rectangle.
The 4th integer corresponds to the breadth of the rectangle.
The output consists of 8 integers.
The first 2 integers correspond to the x and y coordinates the lower left corner of the rectangle
The next 2 integers correspond to the x and y coordinates the upper left corner of the rectangle.
The next 2 integers correspond to the x and y coordinates the upper right corner of the rectangle.
The next 2 integers correspond to the x and y coordinates the lower right corner of the rectangle.
The x and y coordinates of each vertex should be printed on a separate line, separated by a, (comma).
Refer sample input and output for formatting specifications.
Sample Input:
7
6
4
2
Sample Output:
7,6
7,8
11,8
11,6
Program Code:
#include<stdio.h>
int main()
{
int x, y, z, z1;
scanf("%d %d %d %d", &x, &y, &z, &z1);
printf("%d,%d\n",x,y);
printf("%d,%d\n",x,y+z1);
printf("%d,%d\n",x+z,y+z1);
printf("%d,%d\n",x+z,y);
return 0;
}
Post A Comment:
0 comments: