• 小明同学喜欢体育锻炼,他常常去操场上跑步。跑道是一个圆形,在本题中,我们认为跑道是一个半径为R的圆形,设圆心的坐标原点(0,0)。小明跑步的起点坐标为(R,0),他沿着圆形跑道跑步,而且一直沿着一个方向跑步。回到家后,他查看了自己的计步器,计步器显示他跑步的总路程为L。小明想知道自己结束跑步时的坐标,但是他忘记自己是沿着顺时针方向还是逆时针方向跑的了。他想知道在这两种情况下的答案分别是多少。


    include "stdafx.h"

    #include<iostream>  
    #include<vector>  
    #include<string>
    #include<math.h>
    #include<iomanip>
    using namespace std;
    
    
    int main()
    {
    	float L, R;
    	while (cin>>L>>R)
    	{
    		float len = 2 * 3.1415926*R;
    		int nums = L / len;
    	//	cout << "nums:" << nums << endl;
    		float distance = L - nums*len;
    		float jiaodu = distance / R;
    	//	cout << "jiaodu" << jiaodu << endl;
    		if (jiaodu <= 90)
    		{
    			float x1 = R*cos(jiaodu);
    		//	cout << "cos(90):" << acos(90) << endl;
    			float y1 = R*sin(jiaodu);
    	//		cout << "x1:" << x1 << endl;
    	//		cout << "y1:" << y1 << endl;
    
    			float x2 = x1;
    			float y2 = -y1;
    
    	//		cout << "x2:" << x2 << endl;
    	//		cout << "y2:" << y2 << endl;
    
    			cout << setiosflags(ios::fixed) << setprecision(3);
    			cout << x2 << " " << y2 << endl;
    			cout << x1 << " " << y1 << endl;
    			
    		}
    		else if (jiaodu > 90 && jiaodu <= 180)
    		{
    			float x1 = R*sin(jiaodu-90);
    			float y1 = R*cos(jiaodu-90);
    
    			float x2 = x1;
    			float y2 = -y1;
    			cout << setiosflags(ios::fixed) << setprecision(3);
    			cout << x2 << " " << y2 << endl;
    			cout << x1 << " " << y1 << endl;
    		
    		}
    		else if (jiaodu > 180 && jiaodu <= 270)
    		{
    			float x1 = R*cos(jiaodu - 180);
    			float y1 = R*sin(jiaodu-180);
    
    			float x2 = x1;
    			float y2 = -y1;
    			cout << setiosflags(ios::fixed) << setprecision(3);
    			cout << x2 << " " << y2 << endl;
    			cout << x1 << " " << y1 << endl;
    			
    
    		}
    		else
    		{
    			float x1 = R*sin(jiaodu - 270);
    			float y1 = R*cos(jiaodu - 270);
    
    			float x2 = x1;
    			float y2 = -y1;
    			cout << setiosflags(ios::fixed) << setprecision(3);
    			cout << x2 << " " << y2 << endl;
    			cout << x1 << " " << y1 << endl;
    			
    		}
    		
    		
    
    	}
    
    	return 0;
    }
  • 相关阅读:
    关于gc日志中Desired Survivor的疑问和对象晋升老年代的小结
    Tomcat 中部署 web 应用 ---- Dubbo 服务消费者 Web 应用 war 包的部署
    10种常见的排序算法
    让我们来谈谈JDBC
    单例的设计模式
    使用putty与SSHSecureShellClient登录远程服务器完成与本地Git项目的同步
    安装 Dubbo 管理控制台
    邮件工具类
    Hadoop系列教程<一>---Hadoop是什么呢?
    setTimeout闭包常见问题
  • 原文地址:https://www.cnblogs.com/wdan2016/p/6581177.html
Copyright © 2020-2023  润新知