HDU2033 人见人爱A+B

看了别人的代码,在简洁性和泛化能力上有很大差距

//AC
//A和B 都是由3个整数组成,分别表示时分秒,
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack>
#include<map>
#include<cmath>

using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int ah,am,as,bh,bm,bs;
        cin>>ah>>am>>as>>bh>>bm>>bs;

        long long  h=0,m=0,s=0;
        s=bs+as;
        m += (s/60);
        s=s%60;

        m=m+am+bm;
        h+=(m/60);
        m=m%60;

        h=h+ah+bh;

        cout<<h<<" "<<m<<" "<<s<<endl;

    }
}

看一下别人的

s1+= s2;  //其实并不需要马上把该位数值 去 mode 60 

 m1+= ( m2 + s1 / 60 );  

 h1+= ( h2 + m1 / 60 );

 printf("%d %d %d\n" ,h1 ,m1%60 ,s1%60 );
--------------------- 
作者:qie_wei 
来源:CSDN 
原文:https://blog.csdn.net/qie_wei/article/details/70144456 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值