2007-02-20

【Q579】ClockHands

題目: http://acm.uva.es/p/v5/579.html

說明:
  這題不難,不過要注意時針在非整點時會有微小的刻度!

程式下載: http://yaushung.googlepages.com/2007022002.c

程式內容:

#include <stdio.h>

int main() {
int hour, minute ;
float degree ;
while(1) {
scanf("%d:%d", &hour, &minute) ;
if(hour==0 && minute==0)
break ;
if((degree = hour * 30 - minute * 5.5)<0)
degree = -degree ;
printf("%.3f\n", degree>180 ? 360-degree : degree) ;
}
return 0 ;
}

沒有留言: