POJ 2354 Titanic

Source: Internet
Author: User
Tags acos cos

Input is disgusting.

First the latitude and longitude of the time of the second conversion into degrees, and then according to things, south latitude to take the sign. Then according to the two-point distance formula of the ball.

The final attention to the precision to take a larger

#include <stdio.h> #include <math.h>const double Pi=acos ( -1.0); const double Eps=1e-5;int main () {#ifndef    Online_judge freopen ("In.txt", "R", stdin);    #endif//Online_judge double s1[3],s2[3];    int n,a;    Char c1,c2,c3;    Char st[10],s[100];    for (int i=0;i<9;i++) scanf ("%s", s);    scanf ("%lf^%lf '%lf\"%s ", &s1[0],&s1[1],&s1[2],st);    scanf ("%s", s);    Double a1,a2,b1,b2;    a1=s1[0]+s1[1]/60+s1[2]/3600;    if (st[0]== ' S ') a1=-a1;    scanf ("%lf^%lf '%lf\"%s. ", &s1[0],&s1[1],&s1[2],st);    printf ("%lf%lf%lf", s1[0],s1[1],s1[2]);    b1=s1[0]+s1[1]/60+s1[2]/3600;    if (st[0]== ' W ') b1=-b1;    for (int i=0;i<5;i++) scanf ("%s", s);    scanf ("%lf^%lf '%lf\"%s ", &s1[0],&s1[1],&s1[2],st);    a2=s1[0]+s1[1]/60+s1[2]/3600;    if (st[0]== ' S ') a2=-a2;    scanf ("%s", s);    scanf ("%lf^%lf '%lf\"%s ", &s1[0],&s1[1],&s1[2],st);    b2=s1[0]+s1[1]/60+s1[2]/3600;    if (st[0]== ' W ') b2=-b2;    scanf ("%s", s); a1=a1*pi/180;a2=a2*pi/180; b1=b1*pi/180;b2=b2*pi/180;    Double Theta,ans;    Theta=acos (cos (A1) *cos (A2) *cos (B1-B2) +sin (A1) *sin (A2));    Ans=6875*0.5*theta;    printf ("%f", theta);    printf ("The distance to the iceberg:%.2f miles.\n", ans);    if (ans<100-0.005) printf ("danger!\n"); return 0;}


POJ 2354 Titanic

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.