Wednesday, March 18, 2020

  • Session

    Input & Ouput
  • Question ID

    1111110205 : FOUR SEASONERS
  • 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]
  • Logic Test Case 1

    Input (stdin)
    2 4
    
    10 15
    
    5 8
    
    
    Expected Output
    Dinesh\'s house is located at (5.7,9.0)
  • Logic Test Case 2

    Input (stdin)
    2 5
    
    1 2
    
    8 8
    
    
    Expected Output
    Dinesh\'s house is located at (3.7,5.0)


program:

#include <stdio.h>
#include <stdlib.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\\'s house is located at (%0.1f,%0.1f)",a,b);

 return 0;
}


No comments:

Post a Comment

cisco Cybersecurity Essentials Quiz 8 answer in bold

Question  1 Correct Mark 2.00 out of 2.00 Flag question Question text A company has had several incidents involving users downloading unauth...