当我输入 36011 时,它会导致第二个输出是 36011 而不是 11,我确保编译器设置正确设置。我真的不知道还能做什么,我必须使用 long long int 来完成这项任务,当我尝试在我的代码中使用 mod 函数时,它对我不起作用。
#include <iostream>
using namespace std;
int main()
{
long long int seconds;
cin >> seconds;
long long int minutes = seconds / 60;
long long int hours = minutes / 60;
long long int days = hours / 24;
cout << "Total seconds: " << seconds << endl;
if(seconds <= 0)
{
cout << "\nTotal seconds must be greater than zero";
}
else
{
if(days > 0)
{
hours %= 24;
cout << "\n" << days << " day(s)";
}
if(hours > 0)
{
minutes %= 60;
cout << "\n" << hours << " hour(s)";
}
if(minutes > 0)
{
seconds %= 60;
cout << "\n" << minutes << " minute(s)";
}
if(seconds > 0)
{
cout << "\n" << seconds << " second(s)";
}
}
cout << endl;
return 0;}