UVA1122-clock
此题的难点是表盘的规律,时针和分针相遇的时刻是60*hour/11,还有,常疏忽的地方是第一行和最后一行的两句话、
[html]
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
cout<<"program 3 by team x"<<endl;
int a, b, c, d;
cout<<"initial time final time passes"<<endl;
while(cin>>a>>b>>c>>d)
{
int n = c - a;
if(n==0&&d<b) n+=11;
if(n<0)n += 11;
n += 13;
if(((60*(a)/11))<b)n -= 1;
if(c==12)n-=1;
else if(d<((60*(c%12)/11)))n -= 1;
n %= 12;
cout<<" ";
if(a/10==0)cout<<0;
cout<<a<<":";
if(b/10==0)cout<<0;
cout<<b;
cout<<" ";
if(c/10==0)cout<<0;
cout<<c<<":";
if(d/10==0)cout<<0;
cout<<d;
cout<<" ";
if(a==c&&d==b)n=11;
if(n/10==0)cout<<' ';
cout<<n;
cout<<endl;
}cout<<"end of program 3 by team x"<<endl;
return 0;
}
上一篇: Go语言什么时候该使用指针
下一篇: HTML5video基础知识详情