求大佬帮助 互关·
查看原帖
求大佬帮助 互关·
1333712
polyoid楼主2024/12/11 21:46
#include <iostream>
#include<cmath>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int s,v;
	cin>>s>>v;
	int t=ceil(s/v);
	t+=10;
	int maxh=0, maxmin=0; 
	int h=0,m=0;
	for(int i=0;i<24;i++){
		for(int j=0;j<60;j++){
			if(i*60+j+t<480){
				if(i>maxh&&j>maxmin){
						h=i;
						m=j;
				}
			
		}
			}
		}
	
	if(h<=9){
		cout<<"0"<<h<<":";
	}
	else{
		cout<<h<<":";
	}
	if(m<=9){
		cout<<"0"<<m<<endl;
	}
	else{
		cout<<m<<endl;
	}
	return 0;
}

感觉我的代码太复杂了,不知道该怎么优化。。。

2024/12/11 21:46
加载中...