UVA-579 Clock Hands

#include <stdio.h>
int main()
{
    char s;
    double d,ld,h,m,f=180.00;
    while(scanf("%lf %c %lf",&h,&s,&m)!=EOF)
    {
        if(h==0 && m==0)
        {
            break;
        }
        else
        {
            if(m>h)
            {
                d=fabs(((11*m)-(60*h))/2);

                if(d>f)
                {
                    ld=360-d;
                }
                else
                {
                    ld=d;
                }
            }
            else if(h>=m)
            {
                d=fabs(((60*h)-(11*m))/2);
                if(d>f)
                {
                    ld=360-d;
                }
                else
                    {
                        ld=d;
                    }
            }
            printf("%0.3lf\n",ld);

        }
    }
    return 0;
}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment