C++ 80分求助!测试点3、5
查看原帖
C++ 80分求助!测试点3、5
1137152
SmartCirno楼主2023/12/28 13:42
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
typedef struct
{
	int h;
	int m;
}Date;
Date sub(Date&,Date&);
int main()
{
	Date end={7,50};
	float s,v;
	int h=0,m;
	cin>>s>>v;
	m=ceil(s/v);
	while(m>=60)
	{
		m-=60;
		h++;
	}
	Date p={h,m};
	Date res=sub(end,p);
	cout<<setw(2)<<setfill('0')<<res.h<<":"<<res.m;
	return 0;
}

Date sub(Date &a,Date &b)
{
	int h,m;
	m=a.m-b.m;
	h=a.h-b.h;
	if(m<0)
	{
		m+=60;
		h--;
	}
	if(h<0)h+=24;
	Date c={h,m};
	return c;
}

2023/12/28 13:42
加载中...