您的位置:首页 > 其它

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

2017-03-19 17:36 906 查看

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐