| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
偶人品不算太差,为啥总是Wa#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator