c++ primer plus 第六版 第三章习题

第四题:

#include

using namespace std;

int main()

{

long time;

cout << "Enter the number of seconds: ";

cin >> time;

long seconds = time % 60;

long minutes = time/60;

long hours = minutes/60;

minutes = minutes%60;

long days = hours/24;

hours = hours%24;

cout << time << " seconds = "

<< days << " days, "

<< hours << " hours, "

<< minutes << " minutes, "

<< seconds << " seconds "

<< endl;

return 0;

}

你可能感兴趣的:(c++ primer plus 第六版 第三章习题)