Problem Description
Dinesh also joined the group of 3 idiots and now their group is called Four Seasoners. Meanwhile, Binoy has moved to a new house in the same locality. Now the houses of Ajay, Binoy and Chandru are in the located in the shape of a triangle. Dinesh also has moved to a house in the same locality. When Ajay asked Dinesh about the location of his house , Dinesh said that his house is at the centroid from the houses of the other 3. Though Ajay was good in Mathematics, he was puzzled. Can you please help Ajay out?
Given the 3 vertices {(x1,y1), (x2,y2) and (x3,y3)} of a triangle, write a C program to determine the centroid of the 3 vertices.
Input Format:
Input consists of 6 integers. The first integer corresponds to x1 . The second integer corresponds to y1. The third and fouth integers correspond to x2 and y2 respectively.
The fifth and sixth integers correspond to x3 and y3 respectively.
Output Format:
Refer Sample Input and Output for exact formatting specifications.
[All floating point values are displayed correct to 1 decimal place]
·
CODING ARENA::
#include <stdio.h>
int main()
{
float x1,x2,x3,y1,y2,y3;
float x,y;
scanf("%f%f",&x1,&y1);
scanf("%f%f",&x2,&y2);
scanf("%f%f",&x3,&y3);
x=(x1+x2+x3)/3;
y=(y1+y2+y3)/3;
printf("Dinesh\\'s house is located at (%0.1f,%0.1f)",x,y);
return 0;
}
Test Case 1
Input (stdin)
2 4
10 15
5 8
Expected Output
Dinesh\'s house is located at (5.7,9.0)
· Test Case 2
Input (stdin)
2 5
1 2
8 8
Expected Output
Dinesh\'s house is located at (3.7,5.0)
FOR FURTHER CLASSIFICATIONS CONTACT US
ReplyDeleteIt is not correct answer
Deletethis answer is not evaluate
ReplyDelete