练习5

    xiaoxiao2021-03-25  62

    #include <iostream> using namespace std; class Time{ public:     void setTime(int newH,int newM,int newS);     void showTime(); private:     int hour,minute,second; }; void Time::setTime(int newH,int newM,int newS){     hour=newH;     minute=newM;     second=newS; } inline void Time::showTime(){     cout<<hour<<":"<<minute<<":"<<second<<endl; } int main(){     Time mytime;     int x,y,z;     cout<<"Please input time:";     cin>>x>>y>>z;     mytime.setTime(x,y,z);     mytime.showTime();     if(x>12){         mytime.setTime(x-12,y,z);         mytime.showTime();     }     else{         mytime.setTime(x+12,y,z);         mytime.showTime();     }     return 0; }
    转载请注明原文地址: https://ju.6miu.com/read-36508.html

    最新回复(0)