| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
有谁来帮帮本菜?WA十几次了-_-|||,都照着别人的代码打了,怎么还WA呢...#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define sq(a) ((a)*(a))
typedef double T;
double R = 6370;
struct Pt3D
{
T th1, th2;
T x,y,z;
void convert()
{
z = R * cos(th2);
x = R * cos(th1) * sin(th2);
y = R * sin(th1) * sin(th2);
};
};
T dot(Pt3D& a, Pt3D& b){ return a.x*b.x + a.y*b.y + a.z*b.z;}
T norm(Pt3D a){ return sq(a.x)+sq(a.y)+sq(a.z);}
double pi = 3.14159265358979323846264;
Pt3D src, dst;
char input()
{
char s1[10];
T a, b, alpha;
if(scanf("%lf%lf%s", &a, &b, s1) != 3) return 0;
alpha = a+b/60;
if(*s1 == 'N')
alpha =90 - alpha;
else
alpha = 90+ alpha;
src.th2 = pi*alpha/180;
scanf("%lf%lf%s", &a, &b, s1);
alpha = a+b/60;
if(*s1 == 'W')alpha = 360 - alpha;
src.th1 = pi*alpha/180;
scanf("%lf%lf%s", &a, &b, s1);
alpha = a+b/60;
if(*s1 == 'N')
alpha =90 - alpha;
else
alpha =90+ alpha;
dst.th2 = pi*alpha/180;
scanf("%lf%lf%s", &a, &b, s1);
alpha = a+b/60;
if(*s1 == 'W')alpha = 360 -alpha;
dst.th1 = pi*alpha/180;
src.convert();
dst.convert();
return 1;
}
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif
int i, k, lv;
while(input())
{
double th = dot(src,dst)/sqrt(norm(src))/sqrt(norm(dst));
th = acos(th);
printf("%.10lf\n", th*R);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator