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

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.