Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

time.h 最多算到2038年末 因为时间是long类型的

Posted by oipn4e2 at 2008-07-01 17:39:21 on Problem 2080
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator