Wednesday 9 March 2016

FOUR SEASONERS


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 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] 

Sample Input and Output: 
[All text in bold corresponds to input and the rest corresponds to output] 
Enter x1 
Enter y1 
Enter x2 
10 
Enter y2 
15 
Enter x3 
Enter y3 
Dinesh's house is located at (5.7 , 9.0)

Code:
  #include<stdio.h>
int main()
{
  int x1,x2,x3,y1,y2,y3;
  printf("Enter x1\n");
  scanf("%d",&x1);
  printf("Enter y1\n");
  scanf("%d",&y1);
  printf("Enter x2\n");
  scanf("%d",&x2);
  printf("Enter y2\n");
  scanf("%d",&y2);
  printf("Enter x3\n");
  scanf("%d",&x3);
  printf("Enter y3\n");
  scanf("%d",&y3);
  printf("Dinesh's house is located at (%.1f , %.1f)",(float)(x1+x2+x3)/3,(float)(y1+y2+y3)/3);
  return 0;
}
  
  

3 comments:

  1. Please share the above program Inc++

    ReplyDelete
  2. Please share the above program in python

    ReplyDelete
  3. a=float(input())
    b=float(input())
    c=float(input())
    d=float(input())
    print("Binoy's house is located at (",(a+c)/2,",",(b+d)/2,")",sep="")

    """
    here sep stands for seperator we don't want to print space between characters by default the value of seperator is space sep=" " we have changed the value of sep=""(none)
    """

    ReplyDelete