html5教程-UVA1122-clock

发布时间:2018-12-18 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了html5教程-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; 

此题的难点是表盘的规律,时针和分针相遇的时刻是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; 

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! html5教程,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的html5教程-UVA1122-clock全部内容,希望文章能够帮你解决html5教程-UVA1122-clock所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:HTML