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