ZOJ1241题目几何
枚举法的应用
题目如下
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double a,b,c;
int i=1;
cin>>a >>b >>c;
while(a!=0&&b!=0&&c!=0)
{
cout<<"Triangle#"<<i<<endl;
if(a==-1)
{
a=sqrt(c*c-b*b);
if(a<=0||b<=0||c<=0)
cout<<"impossible!"<<endl;
else
cout<<"a="<<a<<endl;
}
else if(b==-1)
{
b=sqrt(c*c-a*a);
if(a<=0||b<=0||c<=0)
cout<<"impossible!"<<endl;
else
cout<<"b="<<b<<endl;
}
else if(c==-1)
{
c=sqrt(a*a+b*b);
cout<<"c="<<c<<endl;
}
i++;
cin>>a>>b>>c;
}
return 0;
}