zoj1199

本文探讨了两个圆相交的数学问题,包括处理圆在特定位置关系下的特殊情况,并介绍了C++中使用cout进行精确输出格式控制的方法。
  • 关键是要考虑到两个两个圆的直径r1==r2的情况和一个圆在另外一个圆内的情况。
  • 顺便,c++输出格式的控制,cout << fixed表示固定小数点,cout << showpoint表示强制显示小数点,cout << setprecision(x)表示输出精度。如果没有cout << fixed作为前缀条件,那么setprecision(x)表示整个输出为数为x位。加上cout << fixed作为条件,那么setprecision(x)表示小数点的为数为x位。
ContractedBlock.gifExpandedBlockStart.gifCode
#include<iostream>
#include
<cmath>
#include
<iomanip>
using namespace std;

int main()
ExpandedBlockStart.gifContractedBlock.gif
{
    
int numberOfCase;
    cin 
>> numberOfCase;
    
for(int i = 0; i < numberOfCase; i ++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
        
int x1, y1, r1, x2, y2, r2;
        cin 
>> x1 >> y1 >> r1
            
>> x2 >> y2 >> r2;
        
double d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        
if((d <= fabs(r1 - r2)) || (x1 == x2 && y1 == y2) || (r1 == r2))
            cout 
<< "Impossible." << endl;
        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
double x = double(r1 * x2 - r2 * x1)/(r1 - r2);
            
double y = double(r1 * y2 - r2 * y1)/(r1 - r2);
            cout 
<< fixed << showpoint;
            cout 
<< setprecision(2<< x << ' ' << y << endl;
        }

    }


    
return 0;
}

转载于:https://www.cnblogs.com/cnlox/archive/2009/03/16/1419392.html

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值