zoe琦 发表于 2013-10-25 20:15:26

C++问题 求助大神

这是我写的程序和运行的结果,但是结果不如预期   求大神帮忙
#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;
}

运行结果



预期结果


zoe琦 发表于 2013-10-25 20:16:09

求助 求助{:5_106:}

zoe琦 发表于 2013-10-26 19:05:03

我顶我顶 我顶顶顶{:5_106:}

CL0419 发表于 2013-10-28 19:58:11

你看这是不是你想要的结果:



页: [1]
查看完整版本: C++问题 求助大神