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

无数次WC,崩溃了......为什么最近我的错总找不出来!AC的朋友过来帮忙看一下错在哪里了......

Posted by cpp0600548281 at 2006-03-05 01:05:43 on Problem 2210
#include <iostream>
#include <cstdio>
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};
using namespace std;
int main(){
	int num;
	cin >>num;
	for(int i=0;i<num;i++){
		int second,minute,hour,day,month,year,allday,allsecond;
		int csecond,cminute,chour,cday,cmonth,cyear;
		scanf("%d:%d:%d %d.%d.%d",&hour,&minute,&second,&day,&month,&year);
		allday=(year-2000)*365+(year-2000)/4-(year-2000)/100+(year-2000)/400;
		if(year%400==0||year%4==0&&year%100!=0)allday+=0;
		else allday+=1;
		if(year%400==0||year%4==0&&year%100!=0){
			for(int k=0;k<month-1;k++)allday+=m2[k];
		}
		else{
			for(int l=0;l<month-1;l++)allday+=m1[l];
		}
		allday+=day-1;
		cyear=allday/1000;
		cmonth=(allday-cyear*1000)/100+1;
		cday=allday%100+1;
		allsecond=hour*3600+minute*60+second;
		allsecond=allsecond*100000/86400;
		chour=allsecond/10000;
		cminute=(allsecond-chour*10000)/100;
		csecond=allsecond%100;
		printf("%d:%d:%d %d.%d.%d\n",chour,cminute,csecond,cday,cmonth,cyear);
	}
	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