社区讨论

求助C++,萌新

学术版参与者 11已保存回复 46

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
46 条
当前快照
1 份
快照标识符
@mi7dm863
此快照首次捕获于
2025/11/20 19:57
4 个月前
此快照最后确认于
2025/11/20 23:46
4 个月前
查看原帖
CPP
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cmath>
using namespace std;
int s,m,h;
int main(){
	string ch;
	cin>>s;
	while(s>=60){
		s-=60;
		m+=1;
	}
	while(m>=60){
		m-=60;
		h+=1;
	}
	ch=h;
	if (strlen(ch)==1)cout<<"0"<<ch<<":";else
	if (strlen(ch) >1)cout<<ch<<":";
	ch=m;
	if (strlen(ch)==1)cout<<"0"<<ch<<":";else
	if (strlen(ch) >1)cout<<ch<<":";
	ch=s;
	if (strlen(ch)==1)cout<<"0"<<ch<<":";else
	if (strlen(ch) >1)cout<<ch<<endl;
	return 0;
}
这个老是编译错误,找不出

回复

46 条回复,欢迎继续交流。

正在加载回复...