TopH Circles in a Rectangle Solution
Solve in C++:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,i;
scanf("%d",&t);
for(i=1; i<=t; i++)
{
double m,n,ra,ca,r,ans;
scanf("%lf",&r);
m=r*4.00;
n=r*2.00;
ra=m*n;
ca=3.1416*r*r;
ans=ra-(2*ca);
printf("Case %d: %.2lf\n",i,ans);
ans=0;
}
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,i;
scanf("%d",&t);
for(i=1; i<=t; i++)
{
double m,n,ra,ca,r,ans;
scanf("%lf",&r);
m=r*4.00;
n=r*2.00;
ra=m*n;
ca=3.1416*r*r;
ans=ra-(2*ca);
printf("Case %d: %.2lf\n",i,ans);
ans=0;
}
}
No comments