í’€ì�´ ¶
세변ì�˜ 길ì�´ê°€ 주어질때 삼ê°�형ì�˜ 내심ì›�ì�˜ 반지름ì�„ 구하는 ë¬¸ì œì�´ë‹¤.
í—¤ë¡ ì�˜ ê³µì‹�ì�„ ì�´ìš©í•´ 세변으로 ë„“ì�´ëŠ” 구하면
í—¤ë¡ ì�˜ ê³µì‹�ì�„ ì�´ìš©í•´ì„œ 구한 ë„“ì�´ = (내심ì›�ì�˜ 반지름 x 세변ì�˜ í•©)/2 로 êµ¬í• ìˆ˜ 있다.
í—¤ë¡ ì�˜ ê³µì‹�ì�„ ì�´ìš©í•´ 세변으로 ë„“ì�´ëŠ” 구하면
소스 ¶
~cpp
#include <iostream>
#include <cmath>
using namespace std;
double a, b, c, halfSum;
void getRadius()
{
halfSum = (a+b+c)/2.0;
if(halfSum==0)
{
cout << "The radius of the round table is: 0.000"<<endl;
return;
}
cout << "The radius of the round table is: " << 1.0*sqrt(halfSum*(halfSum-a)*(halfSum-b)*(halfSum-c))/halfSum << endl;
}
int main()
{
cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
cout.precision(3);
while(cin>>a>>b>>c)
getRadius();
return 0;
}










