Clock


Time Limit: 2 Seconds      Memory Limit: 65536 KB

You are given a standard 12-hour clock with analog display, an hour hand and a minute hand. How many times does the minute hand pass the hour hand in a given time interval?

Sample Input

12 50  1  2
3 8 3 20
2 45 11 0
11 0 3 20
1 2 12 50
3 20 3 8

Sample Output

Program 3 by team X
Initial time Final time Passes
12:50 01:02 0
03:08 03:20 1
02:45 11:00 8
11:00 03:20 4
01:02 12:50 11
03:20 03:08 10
End of program 3 by team X

题目的下边还有一大段,当时出在HUST上,根本分不清哪输出格式是哪个,谁知道最前边最后边那句话也需要。当时有一次试了一下加上这两句,其他地方哪里又出错了。看了题解,直接把最后一次提交的错误代码, 加上这两句输出,直接A了,坑

判断分针和时针相遇的次数

代码如下:

 # include <iostream>
# include<cstdio>
# include<cstring>
using namespace std; int main()
{
int a,b,c,d,ans;
double tmp1,tmp2,tmp3,tmp4;
printf("Program 3 by team X\n");
printf("Initial time Final time Passes\n");
while(scanf("%d%d%d%d",&a,&b,&c,&d)!= EOF)
{
printf(" ");
printf("%02d:%02d",a,b);
printf(" ");
printf("%02d:%02d",c,d);
printf(" ");
if(a==)
a=;
if(c==)
c=;
tmp2 = b/60.0;
tmp1 = a/12.0 + tmp2/12.0;
tmp4 = d/60.0;
tmp3 = c/12.0 + tmp4/12.0;
if(a==c)
{
if(d>=b)
{
if(tmp1-tmp2> && tmp4-tmp3>)
{
ans = ;
}
else
ans = ;
}
else
{
ans = ;
if(tmp1 - tmp2 > )
ans++;
if(tmp4-tmp3>)
ans ++;
}
}
else if(a<c)
{
ans = c-a-;
if(tmp1 - tmp2 > )
ans++;
if(tmp4 - tmp3 > )
ans++;
}
else
{
ans = -a + c -;
if(tmp1 - tmp2 > )
ans++;
if(tmp4 - tmp3>)
ans++;
}
printf("%2d\n",ans);
}
printf("End of program 3 by team X\n");
return ;
}

最新文章

  1. C# XMPP客户端与openfire通信(Matrix Xmpp 授权破解教程)
  2. MySQL Workbench “Error Code: 1175” 的解决方法
  3. js001-JavaScript简介
  4. oracle中时间运算
  5. HDU5115 Dire Wolf(区间DP)
  6. SQL注入原理小结
  7. Cookie与Session的一些总结
  8. T-SQL运算符
  9. [转]Creating Unit Tests for ASP.NET MVC Applications (C#)
  10. 移植FreeModbus+ModbusMaster+STM32至RT-Thread(3、4阶段)
  11. 关闭数据库下的所有连接操作 sql存储过程
  12. 微信小程序之给项目设置id后提示不在合法域名列别中
  13. 洛谷P5245 【模板】多项式快速幂(多项式ln 多项式exp)
  14. scrapy 选择器
  15. laravel框架部署后有用命令
  16. Oracle 数据库实例
  17. 后序线索化二叉树(Java版)
  18. Dynamics CRM 常用的JS
  19. html中怎么样让div并排显示
  20. Spring 框架(一)

热门文章

  1. Codeforces Round #321 (Div. 2) A. Kefa and First Steps 水题
  2. nginx+tomcat动静分离的核心配置
  3. iOS开发——面试笔试精华(一)
  4. android学习日记13--数据存储之SQLite
  5. webService 讲解
  6. 配置SQL Server 2008管理器
  7. jQuery选择器模糊匹配
  8. C#_datatable 写入大量数据_BulkCopy
  9. oracle数据库管理员简介、导入数据与导出数据
  10. Cadence PCB层的概念