1178 – Trapezium

Problem Link

Logic:

 

Area=1/2*(a+c)√(b²-((b²-d²+(a-c)²)/(2(a-c))²)

<Source Code>

#include<stdio.h>
#include<math.h>
#define min(a,b) a<b?a:b
#define PI acos(-1)
int main()
{int t,i;

double a,b,c,d,m,tem=0,x,h,angle,sqa;
scanf(“%d”,&t);
for(i=1;i<=t;i++){
scanf(“%lf %lf %lf %lf”,&a,&b,&c,&d);
if(a>c)
{
c=min(a,c);
}
x=(a-c);
sqa=b*b-d*d+x*x;
sqa=(sqa/(2*x));
sqa=sqa*sqa;
sqa=sqrt(b*b-sqa);

printf(“Case %d: %.7lf\n”,i,(sqa*(a+c)/2));

}
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s