UVA 579 (ClockHands)

Solve in C:

#include<stdio.h>
int main()
{
    float d,s,t;
    int m,h;
    char c;
    while(scanf("%d%c%d",&h,&c,&m)!=EOF)
    {
        if(h<1||h>12||m<0||m>59)
        {
            break;
        }

        else
        {
            d=(11*m-60*h)/2.0;

            if(d>0&&d>180)
            {
                s=360-d;
                printf("%.3f\n",s);
            }
            else if(d>0&&d<181)
                printf("%.3f\n",d);

            else if(d<1)
            {
                s=(-1)*d;;
                if(s>180)
                {
                    t=360-s;
                    printf("%.3f\n",t);
                }
                else
                    printf("%.3f\n",s);
            }

        }
    }

}

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.