GDUFE ACM-1254

题目:http://acm.gdufe.edu.cn/Problem/read/id/1254

 

闹钟人生

Time Limit: 2000/1000ms (Java/Others)

Problem Description:

  已知一个时钟一开始指向0点,顺时针走了n个小时,求它最终所指向的数字(时间按12进制计算)。

Input:

多组输入,每组一个n(-10^7<=n<=10^7)

Output:

输出指针所指数字

Sample Input:

4
12
15

Sample Output:

4
0
3

思路:每12一个循环,注意是逆时针还是顺时针转,还有要注意,每转12个小时,都是指向0而不是12

难度:非常简单

代码:
 1 #include<stdio.h>
 2 int main()
 3 {
 4     long long n;
 5     while(scanf("%lld",&n)!=EOF)
 6     {
 7         if(n<0)
 8             if(n%12==0) printf("0\n");
 9           else printf("%lld\n",12+n%12);
10         else printf("%lld\n",n%12);
11     }
12     return 0;
13 }

 

posted @ 2016-10-28 20:19  ruoruoruoruo  阅读(155)  评论(0编辑  收藏  举报