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

不要混用scanf和cin!!!!!!

Posted by frkstyc at 2006-03-21 21:40:47 on Problem 2210
In Reply To:run time error 求解 Posted by:cpp00548002 at 2006-03-21 21:37:58
> #include<stdio.h>
> #include<iostream.h>
> void main()
> {
> 	char in[40];
> 	int n,i,d,mi,y,h,m,s,ms,rd,rs,a;
> 	int mo[12]={0,31,59,90,120,151,181,212,243,273,304,334};
> 	scanf("%d",&n);
> 	int day,sec,mon,year,hour,min;
> 	for(i=0;i<n;i++)
> 	{
> 		cin.getline(in,40);
> 		sscanf(in,"%d:%d:%d %d.%d.%d",&h,&mi,&s,&d,&m,&y);
> 		a=(y-2000)/400;
> 		y-=a*400;
> 		rd=365*(y-2000)+d+a*97+(y%400)/4-(y%400)/100+mo[m-1];
> 		if((y)%4==0&&((y)%100)!=0&&m>2)
> 			rd+=1;
> 		if(y==2000&&m<3) rd--;
> 		mon=rd/100;
> 		day=rd%100;
> 		year=mon/10;
> 		mon=mon%10;
> 		rs=s+60*mi+3600*h;
> 		ms=rs*1000/(36*24);
> 		hour=ms/10000;
> 		min=(ms/100)%100;
> 		sec=ms%100;
> 		year+=int(146*a);
> 		printf("%d:%d:%d %d.%d.%d\n",hour, min, sec,day+1, mon+1, year );
> 	}
> }

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