题目描述
blablabla
样例
blablabla
C++ 代码
#include<iostream>
#include <ctime>
using namespace std;
int main() {
struct tm t1 = { 0 };
struct tm t2 = { 0 };
int seconds;
int a,b,c,d;
cin>>a>>b>>c>>d;
t1.tm_hour=a;
t1.tm_min=b;
t2.tm_hour=c;
t2.tm_min=d;
seconds = difftime(mktime(&t2), mktime(&t1));//转换结构体为time_t,利用difftime,计算时间差
if(seconds<=0){
seconds+=86400;
}
int hour=seconds/3600;
int min=(seconds%3600)/60;
printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n",hour,min);
return 0;
}
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度分析:blablabla
C++ 代码
blablabla