POJ 1675 Happy Birthday! G++ 余弦定理 背

本文介绍了一个使用C++实现的角度计算程序,通过余弦定理计算平面直角坐标系中三点构成的角度,并对计算出的角度进行调整以确保其在特定范围内,最后比较这些角度是否达到特定阈值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <iostream>
#include <cmath>
using namespace std;
//英语    抄博友程序   余弦定理    背 
double cal(int x1,int y1,int x2,int y2)//抄博友程序  背 
{
	double pi=3.14159265358979;
	double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	double b=sqrt(x1*x1+y1*y1);
	double c=sqrt(x2*x2+y2*y2);
	return acos((b*b+c*c-a*a)/(2*b*c))/pi*180;
} 
double fun(double x)//
{
	if(x>=360)
	{
		x=x-360;
	}
	if(x<0)
	{
		x=360+x;
	}
	if(x>180)
	{
		x=360-x;
	}
	return x;//
}
int main()
{
	int T;
	cin>>T;
	for(int o=0;o<T;o++)
	{
		int r,x1,y1,x2,y2,x3,y3;
		cin>>r>>x1>>y1>>x2>>y2>>x3>>y3;
		if((x1==0&&y1==0)||(x2==0&&y2==0)||(x3==0 && y3==0))//抄博友   英语 
		{
			cout<<"No"<<endl;
			continue; 
		} 
		double a=fun(cal(x1,y1,x2,y2));
		double b=fun(cal(x2,y2,x3,y3));
		double c=fun(cal(x1,y1,x3,y3));
		double t=max(a,b);
		t=max(t,c);
		if(t>=120)//英语 
		{
			cout<<"Yes"<<endl; 
		}else
		{
			cout<<"No"<<endl;
		}
	}
	return 0;
} 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值