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

为什么老是runtime error呢,不懂。谢谢高手同学

Posted by tsunamimj at 2006-03-04 15:10:09 on Problem 2210
#include<iostream.h>
#include<stdio.h>

int g_monthlyDays[2][12] = {{31,28,31,30,31,30,31,31,30,31,30,31},
							{31,29,31,30,31,30,31,31,30,31,30,31}};
bool isLeap(int year); 

void main()
{
	int n,year,month,day;
	long hour,minute,second;
	cin >> n;
	while(n){
		scanf("%ld:%ld:%ld %d.%d.%d",&hour,&minute,&second,&day,&month,&year);
		if(year > 2000)
			day += (year - 2000) * 365 +(year-2001)/4-(year-2001)/100+(year-2001)/400 +1 ;
		for(int i = 0;i < month-1;i ++){
			day += g_monthlyDays[ isLeap(year) ][i];
		}
		day -= 1;
		year = day / (10 * 10 * 10);
		day %= 10 * 10 * 10;
		month = day / 100 + 1;
		day = (day % 100) +1;

		second += hour * 3600 + minute * 60;
		long msec = second * 125 ;
		msec /= 108;
		hour = msec / (100 * 100);
		msec %= 100 * 100;
		minute = msec / 100;
		msec %= 100;

		printf("%ld:%ld:%ld %d.%d.%d\n",hour,minute,msec,day,month,year);
		
		n --;
	}
}

bool isLeap(int year)
{
	return (year%4 == 0) && year%100 || (year%400 == 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