Problem link : UVa 10195 - The Knights Of The Round Table
Solution :
#include<stdio.h>
#include<math.h>
int main()
{
double a,b,c,i,r;
while(scanf("%lf %lf %lf",&a,&b,&c)==3)
{
if(a<=0||b<=0||c<=0)
printf("The radius of the round table is: 0.000\n");
else
{
i=(a+b+c)/2;
r=sqrt((i-a)*(i-b)*(i-c)/i);
printf("The radius of the round table is: %.3lf\n",r);
}
}
return 0;
}
Solution :
#include<stdio.h>
#include<math.h>
int main()
{
double a,b,c,i,r;
while(scanf("%lf %lf %lf",&a,&b,&c)==3)
{
if(a<=0||b<=0||c<=0)
printf("The radius of the round table is: 0.000\n");
else
{
i=(a+b+c)/2;
r=sqrt((i-a)*(i-b)*(i-c)/i);
printf("The radius of the round table is: %.3lf\n",r);
}
}
return 0;
}
No comments:
Post a Comment