Facebook
From Botched Pintail, 1 Year ago, written in C.
Embed
Download Paste or View Raw
Hits: 64
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. double tool(int x1,int y1, int x2, int y2){
  5.     return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
  6. }
  7.  
  8. double masahat(double a,double b, double c){
  9.     double p = (a+b+c)/2;
  10.     return sqrt(p) * sqrt(p-a) * sqrt(p-b) * sqrt(p-c);
  11. }
  12. double max(double a, double b){
  13.     if(a>b) return a;
  14.     return b;
  15. }
  16.  
  17. int main(){
  18.     int n;
  19.     scanf("%i",&n);
  20.     double maxNesbat = -1;
  21.     for(int i = 0; i < n; i++){
  22.         int Ax,Ay,Bx,By,Cx,Cy,Dx,Dy;
  23.         scanf("%i %i %i %i %i %i %i %i",&Ax,&Ay,&Bx,&By,&Cx,&Cy,&Dx,&Dy);
  24.         double AB = tool(Ax,Ay,Bx,By);
  25.         double BC = tool(Bx,By,Cx,Cy);
  26.         double CD = tool(Cx,Cy,Dx,Dy);
  27.         double AC = tool(Ax,Ay,Cx,Cy);
  28.         double AD = tool(Ax,Ay,Dx,Dy);
  29.  
  30.         double masahat4zeli =  masahat(AB,BC,AC) + masahat(AC,AD,CD);
  31.         double mohit = AB + BC + CD + AD;
  32.  
  33.         maxNesbat = max(maxNesbat, masahat4zeli/mohit);
  34.  
  35.         printf("%.2lf\n%.2lf\n",masahat4zeli,mohit);
  36.     }
  37.     printf("%.2lf\n",maxNesbat);
  38. }

Replies to Untitled rss

Title Name Language When
Re: Untitled Violet Agouti c 1 Year ago.