⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1030.cpp

📁 我的URAL的1000 ~ 1050 的全部代码 包含WA 最后AC的程序 有2~3个比较难的是MAIGO的程序
💻 CPP
字号:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
const double D = 6875.;
const double R = 3437.5;
const double C_PI = 3.14159265358979323846;

int main ()
{
double phi1, phi2, teta1, teta2;
double degrees, minutes, seconds, sign;
double x1,x2,y1,y2,z1,z2;
char s[300];

cin.getline(s, 299);
cin.getline(s, 299);
cin.getline(s, 299);
// read the ship coordinates
cin.getline(s, 299);

degrees = atof(s);

char *p = strchr(s,'^');
minutes = atof(p + 1);

p = strchr(s, '\'');
seconds = atof(p + 1);

sign = 0.;
if (strstr(s, "SL") != NULL) sign = -1.;
if (strstr(s, "NL") != NULL) sign = 1.;

phi1 = sign * (degrees + minutes / 60. + seconds / 3600.);

cin >> s;
cin.getline(s, 299);

degrees = atof(s);

p = strchr(s, '^');
minutes = atof(p + 1);

p = strchr(s, '\'');
seconds = atof(p + 1);

sign = 0.;
if (strstr(s,"WL") != NULL) sign=-1.;
if (strstr(s,"EL") != NULL) sign=1.;

teta1 = sign * (degrees + minutes / 60. + seconds / 
3600.);

// skip one line
cin.getline(s, 299);
// read the iceberg coordinates

cin.getline(s, 299);
p = strchr(s,'^');
degrees = atof(s);
minutes = atof(p+1);

p = strchr(s, '\'');
seconds = atof(p+1);

sign = 0.;
if (strstr(s, "SL") != NULL) sign=-1.;
if (strstr(s, "NL") != NULL) sign=1.;

phi2 = sign * (degrees + minutes / 60. + seconds / 3600.);

cin >> s;
cin.getline(s, 299);
degrees = atof(s);
p = strchr(s,'^');
minutes = atof(p + 1);

p = strchr(s, '\'');

seconds = atof(p + 1);

sign = 0.;
if (strstr(s, "WL") != NULL) sign = -1.;
if (strstr(s, "EL") != NULL) sign = 1.;
teta2 = sign * (degrees + minutes / 60. + seconds / 
3600.);

// calculate the euclids coordinate
phi1 = phi1 * C_PI / 180.;
phi2 = phi2 * C_PI / 180.;
teta1 = teta1 * C_PI / 180.;
teta2 = teta2 * C_PI / 180.;

x1 = R * cos(phi1) * cos(teta1);
y1 = R * cos(phi1) * sin(teta1);
z1 = R * sin(phi1);

x2 = R * cos(phi2) * cos(teta2);
y2 = R * cos(phi2) * sin(teta2);
z2 = R * sin(phi2);

double dist = sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2) 
+ (z1-z2) * (z1-z2));
double k = dist / D;
double way = D * asin(k);

printf("The distance to the iceberg: %4.2lf miles.\n", 
way);
if ( 100.00-way>0.005 ) printf("DANGER!\n");

return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -