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 wxn0000 at 2005-03-02 15:36:15 on Problem 1326
#include<iostream>
using namespace std;

struct Info
{
	char loc1[20];
	char loc2[20];
	int mile;
	char code;
	Info *next;
};

struct Case
{
	int mileage;
	Case *next;
};

void main()
{
	Info *infohead,*m;
	Case *head,*n;
	int status;

	infohead=new Info;
	head=new Case;
	m=infohead;
	n=head;
	m->next=NULL;
	n->next=NULL;
	n->mileage=0;

	do
	{
		status=0;
		cin>>m->loc1;
		if(m->loc1[0]!='#')
		{
			status=1;
			n->mileage=0;
			while(m->loc1[0]!='0')
			{
				cin>>m->loc2>>m->mile>>m->code;
				switch(m->code)
				{
				case 'F':n->mileage+=2*(m->mile);break;
				case 'B':n->mileage+=m->mile+int((m->mile)/2+0.5);break;
				case 'Y':
					{
						if(m->mile<=500 && m->mile>=1)
							n->mileage+=500;
						else n->mileage+=m->mile;
						break;
					}
				}
				Info *temp;
				temp=new Info;
				m->next=temp;
				m=temp;
				cin>>m->loc1;
				if(m->loc1=="#")
				{
					status=0;
					break;
				}
			}
			if(status)
			{
				Case *temp;
				temp=new Case;
				n->next=temp;
				n=temp;
				n->next=NULL;
			}
		}
	}while(status);

	for(Case *p=head;p->next!=NULL;p=p->next)
		cout<<p->mileage<<endl;
}

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