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

第十次没过了,向大虾们求救!

Posted by cpp00548702 at 2006-03-07 15:19:58 on Problem 2210
#include<stdio.h>

int m1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int m2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    
int h,m,s,d,mon,y;
void main()
{	
	int n,i=0;
	int hour,minute,second,day,month,year;
	scanf("%d",&n);
	while(i<n)
	{
		int totaldays=0;
		scanf("%d:%d:%d%d.%d.%d",&hour,&minute,&second,&day,&month,&year);
		int j=year-2000;
		if(j!=0)
			totaldays=j*365+(j+3)/4-(j-1)/100+(j-1)/400;

		if(j%400==0||j%100!=0&&j%4==0)
			for(int k1=0;k1<month-1;k1++)
				totaldays+=m2[k1];
		else
			for(int k1=0;k1<month-1;k1++)
				totaldays+=m1[k1];
		totaldays+=day-1;

		y=totaldays/1000;
		mon=(totaldays-y*1000)/100+1;
		d=totaldays-y*1000-(mon-1)*100+1;

		int totalsec1=3600*hour+60*minute+second;
		double totalsec2=(double)totalsec1/86400.0*100000.0;

		h=((int)totalsec2)/10000;
		m=((int)totalsec2-h*10000)/100;
		s=(int)totalsec2-h*10000-m*100;
		printf("%d:%d:%d %d.%d.%d\n",h,m,s,d,mon,y);
		i++;
	}
}
看了很多次,就是不知道错哪了,sigh……

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