• Ural_1030. Titanic


      /*WA到暴了,不能用gets()!!!改成cin.getline() 就过了。把要用的数据都读出来,然后带入一个公式。
    设球上两个点(x1, y1),(x2, y2);
    sum = r*acos(sin(x1)*sin(x2) + cos(x1)*cos(x2)*cos(y1-y2));
    */

    //My Code:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #define E 1e-5

    using namespace std;

    const int N = 100;
    const double pi = acos(-1.0);
    const double r = 3437.5;

    char s[N];
    char dslat[5], delat[5];
    char dslon[5], delon[5];

    int main(){
    //freopen("data.in", "r", stdin);

    int slat, slat1, slat2, elat, elat1, elat2;
    int slon, slon1, slon2, elon, elon1, elon2;

    double lat_s, lat_e, lon_s, lon_e, sum;
    char c;
    cin.getline(s, N);
    cin.getline(s, N);
    cin.getline(s, N);
    scanf("%d%c%d%c%d%c%c%s", &slat, &c, &slat1, &c, &slat2, &c, &c, dslat);
    scanf("%s", s);

    scanf("%d%c%d%c%d%c%c%s", &slon, &c, &slon1, &c, &slon2, &c, &c, dslon);
    getchar(); cin.getline(s, N);

    scanf("%d%c%d%c%d%c%c%s", &elat, &c, &elat1, &c, &elat2, &c, &c, delat);
    scanf("%s", s);

        scanf("%d%c%d%c%d%c%c%s", &elon, &c, &elon1, &c, &elon2, &c, &c, delon);
    getchar(); cin.getline(s, N);

    lat_s = (dslat[0] == 'N'?1:-1)*(slat+(slat1 + slat2/60.0)/60.0)*pi/180.0;
    lon_s = (dslon[0] == 'W'?-1:1)*(slon+(slon1 + slon2/60.0)/60.0)*pi/180.0;
    lat_e = (delat[0] == 'N'?1:-1)*(elat+(elat1 + elat2/60.0)/60.0)*pi/180.0;
    lon_e = (delon[0] == 'W'?-1:1)*(elon+(elon1 + elon2/60.0)/60.0)*pi/180.0;

    sum = r*acos(sin(lat_s)*sin(lat_e)+cos(lat_s)*cos(lat_e)*cos(lon_s - lon_e));

    printf("The distance to the iceberg: %.2lf miles.\n", sum);
    if(100 - sum > 0.005) printf("DANGER!\n");
    return 0;
    }
  • 相关阅读:
    2017光棍节新生训练赛
    javascript模块化编程(二):AMD规范
    javascript模块化编程(一):模块的写法
    CommonJS Promises/A规范
    javascript面向对象(三):非构造函数的继承
    javascript面向对象(二):构造函数的继承
    javascript面向对象(一):封装
    this用法(ryf)
    javascript继承机制的设计思想(ryf)
    XMLHttpRequest对象用法
  • 原文地址:https://www.cnblogs.com/vongang/p/2229243.html
Copyright © 2020-2023  润新知