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> 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator