题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2033
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { int n,residue,quotient; int sum[3]={0},Time[6]={0}; cin>>n; while(n--) { for(int i=0;i<6;i++) { cin>>Time[i]; } sum[0]=Time[0]+Time[3]; sum[1]=Time[1]+Time[4]; sum[2]=Time[2]+Time[5]; if(sum[2]==60) { sum[1]=sum[1]+1; sum[2]=0; } if(sum[2]>60) { quotient=sum[2]/60; sum[2]=sum[2]-quotient*60; sum[1]=sum[1]+quotient; } if(sum[1]==60) { sum[0]=sum[0]+1; sum[1]=0; } if(sum[1]>60) { residue=sum[1]/60; sum[1]=sum[1]-residue*60; sum[0]=sum[0]+residue; } for(int i=0;i<3;i++) { if(i<2) cout<<sum[i]<<" "; else cout<<sum[i]<<endl; } } system("PAUSE"); return EXIT_SUCCESS; }
读懂题就可以了!