您的位置:首页 > 其它

zoj 1241.Geometry Made Simple

2012-10-16 18:08 309 查看
Geometry Made Simple

#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char* argv[])
{
//	ifstream cin("aaa.txt");
int a,b,c,n;
n=0;
cout.precision(3);//有效数字三位
while(cin>>a>>b>>c)
{
if(a==0&&b==0&&c==0)break;
n++;
if(a==-1)
{
if(c*c-b*b<=0)
{
cout<<"Triangle #"<<n<<endl;
cout<<"Impossible."<<endl;
cout<<endl;//产生空行
}
else
{
cout<<"Triangle #"<<n<<endl;
//定点输出
cout<<"a = "<<fixed<<pow(c*c-b*b,.5)<<endl;
cout<<endl;//产生空行
}
}
else if(b==-1)
{
if(c*c-a*a<=0)
{
cout<<"Triangle #"<<n<<endl;
cout<<"Impossible."<<endl;
cout<<endl;//产生空行
}
else
{
cout<<"Triangle #"<<n<<endl;
//定点输出
cout<<"b = "<<fixed<<pow(c*c-a*a,.5)<<endl;
cout<<endl;//产生空行
}
}
else if(c==-1)
{
cout<<"Triangle #"<<n<<endl;
//定点输出
cout<<"c = "<<fixed<<pow(a*a+b*b,.5)<<endl;
cout<<endl;//产生空行
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: