Monday, April 03, 2017

LightOJ Problem:1022 (circle in square)

LightOJ Problem :1022

Circle in Squqre


Problem link:
 http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1022

solution:

#include<stdio.h>
#include<math.h>
#define pi 2*acos(0.0)
int main()
{
    int i,T;
    scanf("%d",&T);
    double radius;
    for(i=1; i<=T; i++)
    {
        scanf("%lf",&radius);
       double width=(2*radius);

        double area=(width*width);
        double circle=(pi*radius*radius);
        double blue=(area-circle);
        printf("Case %d: %.2lf\n",i,blue);
    }
    return 0;
}
//language:C

No comments:

Post a Comment