MFC里面有個(gè)CTime類,你可以拿來(lái)直接用
進(jìn)賢網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),進(jìn)賢網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為進(jìn)賢超過(guò)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營(yíng)銷網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的進(jìn)賢做網(wǎng)站的公司定做!
#include?time.h
#include?assert.h
#include?stdio.h
class?CTimeSpan
{
public:
CTimeSpan()?throw();
CTimeSpan(?__time64_t?time?)?throw();
CTimeSpan(?long?lDays,?int?nHours,?int?nMins,?int?nSecs?)?throw();
__int64?GetDays()?const?throw();
__int64?GetTotalHours()?const?throw();
long?GetHours()?const?throw();
__int64?GetTotalMinutes()?const?throw();
long?GetMinutes()?const?throw();
__int64?GetTotalSeconds()?const?throw();
long?GetSeconds()?const?throw();
__time64_t?GetTimeSpan()?const?throw();
CTimeSpan?operator+(?CTimeSpan?span?)?const?throw();
CTimeSpan?operator-(?CTimeSpan?span?)?const?throw();
CTimeSpan?operator+=(?CTimeSpan?span?)?throw();
CTimeSpan?operator-=(?CTimeSpan?span?)?throw();
bool?operator==(?CTimeSpan?span?)?const?throw();
bool?operator!=(?CTimeSpan?span?)?const?throw();
bool?operator(?CTimeSpan?span?)?const?throw();
bool?operator(?CTimeSpan?span?)?const?throw();
bool?operator=(?CTimeSpan?span?)?const?throw();
bool?operator=(?CTimeSpan?span?)?const?throw();
private:
__time64_t?m_timeSpan;
};
inline?CTimeSpan::CTimeSpan()?throw()?:?
m_timeSpan(0)
{
}
inline?CTimeSpan::CTimeSpan(?__time64_t?time?)?throw()?:?
m_timeSpan(?time?)
{
}
inline?CTimeSpan::CTimeSpan(long?lDays,?int?nHours,?int?nMins,?int?nSecs)?throw()
{
m_timeSpan?=?nSecs?+?60*?(nMins?+?60*?(nHours?+?__int64(24)?*?lDays));
}
inline?__int64?CTimeSpan::GetDays()?const?throw()
{
return(?m_timeSpan/(24*3600)?);
}
inline?__int64?CTimeSpan::GetTotalHours()?const?throw()
{
return(?m_timeSpan/3600?);
}
inline?long?CTimeSpan::GetHours()?const?throw()
{
return(?long(?GetTotalHours()-(GetDays()*24)?)?);
}
inline?__int64?CTimeSpan::GetTotalMinutes()?const?throw()
{
return(?m_timeSpan/60?);
}
inline?long?CTimeSpan::GetMinutes()?const?throw()
{
return(?long(?GetTotalMinutes()-(GetTotalHours()*60)?)?);
}
inline?__int64?CTimeSpan::GetTotalSeconds()?const?throw()
{
return(?m_timeSpan?);
}
inline?long?CTimeSpan::GetSeconds()?const?throw()
{
return(?long(?GetTotalSeconds()-(GetTotalMinutes()*60)?)?);
}
inline?__time64_t?CTimeSpan::GetTimeSpan()?const?throw()
{
return(?m_timeSpan?);
}
inline?CTimeSpan?CTimeSpan::operator+(?CTimeSpan?span?)?const?throw()
{
return(?CTimeSpan(?m_timeSpan+span.m_timeSpan?)?);
}
inline?CTimeSpan?CTimeSpan::operator-(?CTimeSpan?span?)?const?throw()
{
return(?CTimeSpan(?m_timeSpan-span.m_timeSpan?)?);
}
inline?CTimeSpan?CTimeSpan::operator+=(?CTimeSpan?span?)?throw()
{
m_timeSpan?+=?span.m_timeSpan;
return(?*this?);
}
inline?CTimeSpan?CTimeSpan::operator-=(?CTimeSpan?span?)?throw()
{
m_timeSpan?-=?span.m_timeSpan;
return(?*this?);
}
inline?bool?CTimeSpan::operator==(?CTimeSpan?span?)?const?throw()
{
return(?m_timeSpan?==?span.m_timeSpan?);
}
inline?bool?CTimeSpan::operator!=(?CTimeSpan?span?)?const?throw()
{
return(?m_timeSpan?!=?span.m_timeSpan?);
}
inline?bool?CTimeSpan::operator(?CTimeSpan?span?)?const?throw()
{
return(?m_timeSpan??span.m_timeSpan?);
}
inline?bool?CTimeSpan::operator(?CTimeSpan?span?)?const?throw()
{
return(?m_timeSpan??span.m_timeSpan?);
}
inline?bool?CTimeSpan::operator=(?CTimeSpan?span?)?const?throw()
{
return(?m_timeSpan?=?span.m_timeSpan?);
}
inline?bool?CTimeSpan::operator=(?CTimeSpan?span?)?const?throw()
{
return(?m_timeSpan?=?span.m_timeSpan?);
}
class?CTime
{
public:
static?CTime?__stdcall?GetCurrentTime()?throw();
CTime()?throw();
CTime(?__time64_t?time?)?throw();
CTime(?int?nYear,?int?nMonth,?int?nDay,?int?nHour,?int?nMin,?int?nSec,
int?nDST?=?-1?);
CTime(?unsigned?short?wDosDate,?unsigned?short?wDosTime,?int?nDST?=?-1?);
CTime?operator=(?__time64_t?time?)?throw();
CTime?operator+=(?CTimeSpan?span?)?throw();
CTime?operator-=(?CTimeSpan?span?)?throw();
CTimeSpan?operator-(?CTime?time?)?const?throw();
CTime?operator-(?CTimeSpan?span?)?const?throw();
CTime?operator+(?CTimeSpan?span?)?const?throw();
bool?operator==(?CTime?time?)?const?throw();
bool?operator!=(?CTime?time?)?const?throw();
bool?operator(?CTime?time?)?const?throw();
bool?operator(?CTime?time?)?const?throw();
bool?operator=(?CTime?time?)?const?throw();
bool?operator=(?CTime?time?)?const?throw();
struct?tm*?GetGmtTm(?struct?tm*?ptm?)?const;
struct?tm*?GetLocalTm(?struct?tm*?ptm?)?const;
__time64_t?GetTime()?const?throw();
int?GetYear()?const?throw();
int?GetMonth()?const?throw();
int?GetDay()?const?throw();
int?GetHour()?const?throw();
int?GetMinute()?const?throw();
int?GetSecond()?const?throw();
int?GetDayOfWeek()?const?throw();
private:
__time64_t?m_time;
};
inline?CTime?__stdcall?CTime::GetCurrentTime()?throw()
{
return(?CTime(?::_time64(?NULL?)?)?);
}
inline?CTime::CTime()?throw()?:?
m_time(0)
{
}
inline?CTime::CTime(?__time64_t?time?)?throw():?
m_time(?time?)
{
}
inline?CTime::CTime(int?nYear,?int?nMonth,?int?nDay,?int?nHour,?int?nMin,?int?nSec,
int?nDST)
{
#pragma?warning?(push)
#pragma?warning?(disable:?4127)?//?conditional?expression?constant
assert(?nYear?=?1900?);
assert(?nMonth?=?1??nMonth?=?12?);
assert(?nDay?=?1??nDay?=?31?);
assert(?nHour?=?0??nHour?=?23?);
assert(?nMin?=?0??nMin?=?59?);
assert(?nSec?=?0??nSec?=?59?);
#pragma?warning?(pop)
struct?tm?atm;
atm.tm_sec?=?nSec;
atm.tm_min?=?nMin;
atm.tm_hour?=?nHour;
atm.tm_mday?=?nDay;
atm.tm_mon?=?nMonth?-?1;?//?tm_mon?is?0?based
atm.tm_year?=?nYear?-?1900;?//?tm_year?is?1900?based
atm.tm_isdst?=?nDST;
m_time?=?_mktime64(atm);
assert(m_time?!=?-1);?//?indicates?an?illegal?input?time
}
inline?CTime::CTime(unsigned?short?wDosDate,?unsigned?short?wDosTime,?int?nDST)
{
struct?tm?atm;
atm.tm_sec?=?(wDosTime??~0xFFE0)??1;
atm.tm_min?=?(wDosTime??~0xF800)??5;
atm.tm_hour?=?wDosTime??11;
atm.tm_mday?=?wDosDate??~0xFFE0;
atm.tm_mon?=?((wDosDate??~0xFE00)??5)?-?1;
atm.tm_year?=?(wDosDate??9)?+?80;
atm.tm_isdst?=?nDST;
m_time?=?_mktime64(atm);
assert(m_time?!=?-1);?//?indicates?an?illegal?input?time
}
inline?CTime?CTime::operator=(?__time64_t?time?)?throw()
{
m_time?=?time;
return(?*this?);
}
inline?CTime?CTime::operator+=(?CTimeSpan?span?)?throw()
{
m_time?+=?span.GetTimeSpan();
return(?*this?);
}
inline?CTime?CTime::operator-=(?CTimeSpan?span?)?throw()
{
m_time?-=?span.GetTimeSpan();
return(?*this?);
}
inline?CTimeSpan?CTime::operator-(?CTime?time?)?const?throw()
{
return(?CTimeSpan(?m_time-time.m_time?)?);
}
inline?CTime?CTime::operator-(?CTimeSpan?span?)?const?throw()
{
return(?CTime(?m_time-span.GetTimeSpan()?)?);
}
inline?CTime?CTime::operator+(?CTimeSpan?span?)?const?throw()
{
return(?CTime(?m_time+span.GetTimeSpan()?)?);
}
inline?bool?CTime::operator==(?CTime?time?)?const?throw()
{
return(?m_time?==?time.m_time?);
}
inline?bool?CTime::operator!=(?CTime?time?)?const?throw()
{
return(?m_time?!=?time.m_time?);
}
inline?bool?CTime::operator(?CTime?time?)?const?throw()
{
return(?m_time??time.m_time?);
}
inline?bool?CTime::operator(?CTime?time?)?const?throw()
{
return(?m_time??time.m_time?);
}
inline?bool?CTime::operator=(?CTime?time?)?const?throw()
{
return(?m_time?=?time.m_time?);
}
inline?bool?CTime::operator=(?CTime?time?)?const?throw()
{
return(?m_time?=?time.m_time?);
}
inline?struct?tm*?CTime::GetGmtTm(struct?tm*?ptm)?const
{
//?Ensure?ptm?is?valid
assert(?ptm?!=?NULL?);
if?(ptm?!=?NULL)
{
struct?tm?ptmTemp;
errno_t?err?=?_gmtime64_s(ptmTemp,?m_time);
//?Be?sure?the?call?succeeded
if(err?!=?0)?{?return?NULL;?}
*ptm?=?ptmTemp;
return?ptm;
}
return?NULL;
}
inline?struct?tm*?CTime::GetLocalTm(struct?tm*?ptm)?const
{
//?Ensure?ptm?is?valid
assert(?ptm?!=?NULL?);
if?(ptm?!=?NULL)
{
struct?tm?ptmTemp;
errno_t?err?=?_localtime64_s(ptmTemp,?m_time);
if?(err?!=?0)
{
return?NULL;?//?indicates?that?m_time?was?not?initialized!
}
*ptm?=?ptmTemp;
return?ptm;
}
return?NULL;
}
inline?__time64_t?CTime::GetTime()?const?throw()
{
return(?m_time?);
}
inline?int?CTime::GetYear()?const
{?
struct?tm?ttm;
struct?tm?*?ptm;
ptm?=?GetLocalTm(ttm);
return?ptm???(ptm-tm_year)?+?1900?:?0?;?
}
inline?int?CTime::GetMonth()?const
{?
struct?tm?ttm;
struct?tm?*?ptm;
ptm?=?GetLocalTm(ttm);
return?ptm???ptm-tm_mon?+?1?:?0;
}
inline?int?CTime::GetDay()?const
{
struct?tm?ttm;
struct?tm?*?ptm;
ptm?=?GetLocalTm(ttm);
return?ptm???ptm-tm_mday?:?0?;?
}
inline?int?CTime::GetHour()?const
{
struct?tm?ttm;
struct?tm?*?ptm;
ptm?=?GetLocalTm(ttm);
return?ptm???ptm-tm_hour?:?-1?;?
}
inline?int?CTime::GetMinute()?const
{
struct?tm?ttm;
struct?tm?*?ptm;
ptm?=?GetLocalTm(ttm);
return?ptm???ptm-tm_min?:?-1?;?
}
inline?int?CTime::GetSecond()?const
{?
struct?tm?ttm;
struct?tm?*?ptm;
ptm?=?GetLocalTm(ttm);
return?ptm???ptm-tm_sec?:?-1?;
}
inline?int?CTime::GetDayOfWeek()?const
{?
struct?tm?ttm;
struct?tm?*?ptm;
ptm?=?GetLocalTm(ttm);
return?ptm???ptm-tm_wday?+?1?:?0?;
}
void?date()
{
CTime?together?=?CTime(2013,?6,?22,?12,?30,?30);
CTime?now?=?CTime::GetCurrentTime();
CTimeSpan?left=now-together;
printf("%ld天",left.GetDays());
printf("%02ld時(shí)",left.GetHours());
printf("%02ld分",left.GetMinutes());
printf("%02ld秒",left.GetSeconds());
}
void?main()
{
date();
}
var?a?=?["a","b","c"];
var?b?=?a.reverse();?//?b的結(jié)果為["c",?"b",?"a"]
這個(gè)地址可以完美的給你回答,另外你要學(xué)會(huì)百度,先百度再提問(wèn)。你的問(wèn)題可以描述為數(shù)組反轉(zhuǎn)
java是不能夠編譯C/C++文件的。他們?cè)硗耆煌1澈蟮倪\(yùn)行機(jī)制也完全不一樣。
C/C++源文件只能夠用C/C++的編譯器來(lái)編譯。
以GCC編譯器為例,整個(gè)編譯可以分為四步。
第一步是預(yù)處理,包括語(yǔ)法檢查等工作。
gcc -P abc.c
第二步由源程序生產(chǎn)匯編語(yǔ)言代碼。
gcc -S abc.c
會(huì)生成abc.s文件,這個(gè)文件里就是匯編代碼。
第三步編譯器生成目標(biāo)代碼,一個(gè)源文件生成一個(gè)目標(biāo)代碼。
gcc -c abc.c
會(huì)生成abc.o
第四步連接器從目標(biāo)代碼生成可執(zhí)行文件。
gcc abc.o
目標(biāo)代碼包括機(jī)器碼和符號(hào)表(函數(shù)及變量名)。連接器的主要作用是通過(guò)符號(hào)表在庫(kù)文件和其他模塊中找到在目標(biāo)代碼中引入或未定義的符號(hào)(函數(shù)及變量名),將幾個(gè)目標(biāo)代碼合成可執(zhí)行文件。
本文標(biāo)題:javascript轉(zhuǎn)c,javascript轉(zhuǎn)c語(yǔ)言
分享URL:http://www.rwnh.cn/article10/dscojgo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站制作、全網(wǎng)營(yíng)銷推廣、軟件開發(fā)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)