c语言字母怎么做加法,C 语言 怎么做时间的加法

C/C++ code#include

#include

#include

int main(int argc, TCHAR* argv[]) {

COleDateTime t;

COleDateTimeSpan ts;

CString s,fmt;

int nYear;

int nMonth;

int nDay;

int nHour;

int nMin;

int nSec;

int lDays;

int nHours;

int nMins;

int nSecs;

int i,N;

// initialize MFC and print and error on failure

if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {

printf("Fatal Error: MFC initialization failed\n");

return 1;

}

if (argc<13) {

printf("Usage:%s sYYYY sMM sDD shh smm sss pDD phh pmm pss n {SQL|YYYY|YY}\n",argv[0]);

return 2;

}

if (stricmp(argv[12],"SQL")==0) fmt="%Y-%m-%d %H:%M:%S";

else if (stricmp(argv[12],"YYYY")==0) fmt="%Y%m%d %H%M%S";

else if (stricmp(argv[12],"YY")==0) fmt="%y%m%d %H%M%S";

else {

printf("Usage:%s sYYYY sMM sDD shh smm sss pDD phh pmm pss n {SQL|YYYY|YY}\n",argv[0]);

return 3;

}

nYear =atoi(argv[ 1]);

nMonth=atoi(argv[ 2]);

nDay =atoi(argv[ 3]);

nHour =atoi(argv[ 4]);

nMin =atoi(argv[ 5]);

nSec =atoi(argv[ 6]);

lDays =atoi(argv[ 7]);

nHours=atoi(argv[ 8]);

nMins =atoi(argv[ 9]);

nSecs =atoi(argv[10]);

N =atoi(argv[11]);

if (N<=0) {

printf("Usage:%s sYYYY sMM sDD shh smm sss pDD phh pmm pss n {SQL|YYYY|YY}\n",argv[0]);

return 4;

}

t=COleDateTime( nYear, nMonth, nDay, nHour, nMin, nSec);

ts=COleDateTimeSpan( lDays, nHours, nMins, nSecs );

for (i=1;i<=N;i++) {

s=t.Format(fmt);

printf("%08d %s\n",i,s);

t=t+ts;

}

return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值