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 equidistant 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 point which is equidistant from all 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 fourth integers correspond to x2 and y2 respectively.
The fifth and sixth integers correspond to x3 and y3 respectively.CODING ARENA
#include <stdio.h>
int main()
{
int x1,x2,x3,y1,y2,y3;
float a,b;
Scanf("%d%d%d%d%d%d",&x1&y1&x2&y2&x3&y3);
a=(float) (x1+x2+x3)/3.0;
b=(float) (y1+y2+y3)/3.0
printf("Dinesh house is located at (%0.1f,%0.1f)",a,b);
return 0;
}
Test Case 1
Input (stdin)2 4 10 15 5 8
Expected OutputDinesh house is located at (5.7,9.0)
Test Case 2
Input (stdin)3 6 12 17 7 9
Expected OutputDinesh house is located at (7.3,10.7)
there are many simple mistakes in this progam like scanf with capital s;
ReplyDeleteabsence of commas between &x1&y1 etc.
but thanks for your hardwork