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
解题思路:水题!!!取余。但是要注意的一点,负数取余任何一个不为0的数之后都是负数,又要求输出是12进制的,负数说明逆时针转,所以要将其调整成正数,再单一出口取余输出。水过。
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     while(cin>>n){
 7         while(n<0)n+=12;
 8         cout<<(n%12)<<endl;
 9     }
10     return 0;
11 }

 

相关文章:

  • 2021-04-28
  • 2021-10-22
  • 2021-10-31
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2021-06-01
猜你喜欢
  • 2021-10-13
  • 2021-05-19
  • 2021-07-22
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
相关资源
相似解决方案