| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
time.h 最多算到2038年末 因为时间是long类型的In Reply To:调用标准库<time.h>函数,为什么还是WA?不解! Posted by:nanhuacrab at 2007-10-07 13:04:06 > #include <time.h>
> #include <stdio.h>
>
> #define SECONDS 3600 * 24
>
> int main( ) {
>
> int n;
> time_t t;
> struct tm *newTime;
> char buff[80];
>
> t = ( 365 * 30 + 7 ) * SECONDS;
>
> while ( scanf( "%d", &n ) && n != -1 ) {
> t += n * SECONDS;
> //newTime = localtime( &t );
> newTime = gmtime( &t );
> t -= n * SECONDS;
> strftime( buff, 80, "%Y-%m-%d %A", newTime );
> puts( buff );
> }
>
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator