求指正!!卡在90分了
查看原帖
求指正!!卡在90分了
983343
李煦风楼主2023/11/12 01:34
#include <iostream>
#include<cmath>
using namespace std;
int main() {
	int s, v;//创建变量距离和速度
	cin >> s >> v;
	double time = (s * 1.0) / (v * 1.0);//创建变量时间time

	if (time - int(time) != 0) {//如果变量time为小数
		time = ceil(time);//将变量time向上取整
	}
	if (time <= 60) {//如果变量time小于一小时直接输出
		cout << "07:" << 60 - time - 10;
	}
	else {
		int h, m;//创建小时和分钟
		int t = time;
		if (t < 480) {//如果在一天之内就用8小时减
			t = 480 - t-10;
			h = t / 60;
			m = t % 60;
			if (m == 0) {
				cout << "0" << h << ":" << "00";
			}
			if (m < 10 && m != 0) {
				cout << "0" << h << ":" << "0" << m;
			}
			if (m >= 10) {
				cout << "0" << h << ":" << m;
			}

			return 0;
		}
		else {
			t = 1440 - (t - 480) - 10;
			h = t / 60;
			m = t % 60;
			if (h >= 10) {
				if (m == 0) {
					cout << h << ":" << "00";
				}
				if (m < 10 && m != 0) {
					cout << h << ":" << "0" << m;
				}
				if (m >= 10) {
					cout << h << ":" << m;
				}
			}
			else {
				if (m == 0) {
					cout << "0" << h << ":" << "00";
				}
				if (m < 10 && m != 0) {
					cout << "0" << h << ":" << "0" << m;
				}
				if (m >= 10) {
					cout << "0" << h << ":" << m;
				}

			}

			return 0;

		}


	}
	return 0;
}

2023/11/12 01:34
加载中...