看了别人的代码,在简洁性和泛化能力上有很大差距
//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
版权声明:本文为博主原创文章,转载请附上博文链接!