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

高手能指点一下我哪里错了吗?为什么一直是WA!!!!

Posted by cpp0600548281 at 2006-03-08 22:06:37 on Problem 2351
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
void counttime(int& chour,int& cminute,string start,string end);
int main(){
	int n;
	cin >>n;
	while(n--){
		char time[9];
		string tag,start,end;
		cin >>time;
		if(strcmp(time,"noon")==0||strcmp(time,"midnight")==0)cin >>start>>end;
		else cin >>tag>>start>>end;
		if(strcmp(time,"noon")==0){
			strcpy(time,"12:00");
			tag="p.m.";
		}
		if(strcmp(time,"midnight")==0){
			strcpy(time,"12:00");
			tag="a.m.";
		}
		int hour=0,minute=0,chour=0,cminute=0;
		sscanf(time,"%d:%d",&hour,&minute);	
		counttime(chour,cminute,start,end);
		minute=minute+cminute;
		if(minute>=-60&&minute<0){
			hour-=1;minute=60+minute;
		}
		else if(minute>=60&&minute<120){
			hour+=1;minute=minute-60;
		}	
		if(hour==12)hour=0;
		if(tag=="p.m.")hour=hour+12;
		hour=hour+chour;
		if(hour<0)hour=hour+24;
		else if(hour>=24)hour=hour-24;
		if(hour==0&&minute==0)cout <<"midnight"<<endl;
		else if(hour==12&&minute==0)cout <<"noon"<<endl;
		else if(hour>0&&hour<12||hour==0&&minute!=0){
			if(hour==0)hour=12;
			if(minute>=0&&minute<=9)printf("%d:0%d %s\n",hour,minute,"a.m.");
			else printf("%d:%d %s\n",hour,minute,"a.m.");
		}
		else if(hour>12&&hour<24||hour==12&&minute!=0){
			if(minute>=0&&minute<=9)printf("%d:0%d %s\n",hour-12,minute,"p.m.");
			else printf("%d:%d %s\n",hour-12,minute,"p.m.");
		}
	}
	return 0;
}

void counttime(int& chour,int& cminute,string start,string end){
	int a,b,c=0,d=0;
	if(start=="UTC"||start=="GMT"||start=="WET")a=0,c=0;
	else if(start=="BST"||start=="IST"||start=="WEST"||start=="CET")a=1,c=0;
	else if(start=="CEST"||start=="EET")a=2,c=0;
	else if(start=="EEST"||start=="MSK")a=3,c=0;
	else if(start=="MSD")a=4,c=0;
	else if(start=="AWST")a=8,c=0;
	else if(start=="ACST")a=9,c=30;
	else if(start=="AEST")a=10,c=0;
	else if(start=="ACDT")a=10,c=30;
	else if(start=="AEDT")a=11,c=0;
	else if(start=="NDT")a=-2,c=-30;
	else if(start=="ADT")a=-3,c=0;
	else if(start=="NST")a=-3,c=-30;
	else if(start=="AST"||start=="EDT")a=-4,c=0;
	else if(start=="EST"||start=="CDT")a=-5,c=0;
	else if(start=="CST"||start=="MDT")a=-6,c=0;
	else if(start=="MST"||start=="PDT")a=-7,c=0;
	else if(start=="PST"||start=="AKDT")a=-8,c=0;
	else if(start=="AKST")a=-9,c=0;
	else if(start=="HST")a=-10,c=0;
	if(end=="UTC"||end=="GMT"||end=="WET")b=0,d=0;
	else if(end=="BST"||end=="IST"||end=="WEST"||end=="CET")b=1,d=0;
	else if(end=="CEST"||end=="EET")b=2,d=0;
	else if(end=="EEST"||end=="MSK")b=3,d=0;
	else if(end=="MSD")b=4,d=0;
	else if(end=="AWST")b=8,d=0;
	else if(end=="ACST")b=9,d=30;
	else if(end=="AEST")b=10,d=0;
	else if(end=="ACDT")b=10,d=30;
	else if(end=="AEDT")b=11,d=0;
	else if(end=="NDT")b=-2,d=-30;
	else if(end=="ADT")b=-3,d=0;
	else if(end=="NST")b=-3,d=-30;
	else if(end=="AST"||end=="EDT")b=-4,d=0;
	else if(end=="EST"||end=="CDT")b=-5,d=0;
	else if(end=="CST"||end=="MDT")b=-6,d=0;
	else if(end=="MST"||end=="PDT")b=-7,d=0;
	else if(end=="PST"||end=="AKDT")b=-8,d=0;
	else if(end=="AKST")b=-9,d=0;
	else if(end=="HST")b=-10,d=0;
	chour=b-a;
	cminute=d-c;
}

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