?? 2_5.cpp
字號(hào):
// 2_5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
#include "time.h"
class Time{
public:
atime();
void settime(int ,int ,int );
void printstandard();
private:
int hour;
int minute;
int second;
};
Time::atime()
{
time_t ltime;
time(<ime);
struct tm *nowtime;
nowtime=localtime(<ime);
hour=nowtime->tm_hour;
minute=nowtime->tm_min;
second=nowtime->tm_sec;
}
void Time::settime(int h,int m,int s)
{
hour=(h>=0&&h<24)?h:0;
minute=(m>=0&&m<60)?m:0;
second=(s>=0&&s<60)?s:0;
}
void Time::printstandard()
{
cout<<((hour==0||hour==12)?12:hour%12)
<<":"<<(minute<10?"0":"")<<minute
<<":"<<(second<10?"0":"")<<second
<<(hour<12?"AM":"PM")
<<'\n';
}
main()
{
Time t;
t.atime();
t.printstandard();
t.settime(44,77,122);
t.printstandard();
return 0;
}
//_strtime(tmpbuf)
//char tmpbuf[11]
//n=ltime-(365*24*3600)*(ltime/(365*24*3600))-(ltime/(365*24*3600))/4*24*3600;
//h=n-(n/(24*3600))*24*3600;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -