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 00448224 at 2005-03-10 22:44:07 on Problem 1326
#include<iostream.h>
#include<math.h>
struct Infor
{
	char p1[20];
	char p2[20];
	int mile;
	char ch;
	Infor * next;
};
struct Case
{
	int mileage;
	Case *next;
};
void main()
{
	int s;
	Infor * head1,* m;
	Case * head2,* n;
	head1=new Infor;
	head2=new Case;
	m=head1;
	n=head2;
	m->next=NULL;
	n->next=NULL;
	n->mileage=0;
	do
	{
		s=0;
		cin>>m->p1;
		if(m->p1[0]!='#')
		{
			s=1;
			n->mileage=0;
			while(m->p1[0]!='0')
			{
				cin>>m->p2>>m->mile>>m->ch;
				switch(m->ch)
				{
				case 'F':n->mileage+=2*(m->mile);break;
				case 'B':n->mileage+=m->mile+(int)ceil(m->mile/2);break;
				case 'Y':
					{
						if(m->mile<=500 && m->mile>=1)
							n->mileage+=500;
						else n->mileage+=m->mile;
						break;
					}
				}
				Infor * temp;
				temp=new Infor;
				m->next=temp;
				m=temp;
				cin>>m->p1;
				if(m->p1=="#")
				{
					s=0;
					break;
				}
			}
			if(s)
			{
				Case * temp;
				temp=new Case;
				n->next=temp;
				n=temp;
				n->next=NULL;
			}
		}

	}while(s);
		for(Case * p=head2;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