|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这是我写的程序和运行的结果 , 但是结果不如预期 求大神帮忙
#include <iostream>
#include <ctime>
using namespace std;
void second (int elapseTime)
{
int totalSeconds = time(0);
int currentSecond = totalSeconds % 60;
int totalMinutes = totalSeconds/60;
int currentMinute = totalMinutes % 60;
int totalHours = totalMinutes / 60;
int currentHour = totalHours % 24;
}
void setTime (int elapseTime)
{
int totalSeconds = time(0);
int currentSecond = totalSeconds % 60;
int totalMinutes = totalSeconds/60;
int currentMinute = totalMinutes % 60;
int totalHours = totalMinutes / 60;
int currentHour = totalHours % 24;
cout<<currentHour<<":"<<currentMinute<<":"<<currentSecond<<endl;
}
void Print()
{
cout<<"...................................................................."<<endl ;
}
int main()
{ string name;
int hour,minute,second;
cout <<" Time Program using Time Class :";
getline(cin,name);
Print();
cout<<"The current GMT - Greenwich mean time is ...."<<endl;
Print();
cout<<"HR:MN:SE"<<endl ;
setTime (0);
Print();
cout<<"The current Beijing calculated time is ...."<<endl ;
Print();
cout<<"HR:MN:SE"<<endl ;
time_t hold_time;
hold_time=time(NULL);
cout<<ctime(&hold_time);
Print();
cout<<"If the elapsed time was 555550 seconds then the GMT would be ....."<<endl ;
Print();
cout<<"HR:MN:SE"<<endl ;
setTime (555550);
return 0;
}
运行结果
预期结果
预期结果
|
|