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 |
请高人帮我该该。#include<stdio.h> #include<malloc.h> #include<string.h> #define len sizeof(struct mile) int sum; struct mile { char add1[100]; char add2[100]; int m; char cl; struct mile *next; }; int main() { char c; struct mile *p1,*p2,*head; while(1) { p1=p2=(struct mile*)malloc(len); scanf("%s %s %d %c",p1->add1,p1->add2,&p1->m,&p1->cl); if((p1->cl)=='F') sum=(p1->m)*2; else if(p1->cl=='B') sum=p1->m+(p1->m+1)/2; else if(p1->cl=='Y') { if(p1->m>500) sum=p1->m; if(p1->m<=500) sum=500; } int n=0; head=0; while(1) { n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct mile*)malloc(len); scanf("%s",p1->add1); if(strcmp(p1->add1,"0")==0) break; scanf("%s %d %c",p1->add2,&p1->m,&p1->cl); if(p1->cl=='F') sum+=(p1->m)*2; else if(p1->cl=='B') sum+=p1->m+(p1->m+1)/2; else if(p1->cl=='Y') { if(p1->m>500) sum+=p1->m; if(p1->m<=500) sum+=500; } } p2=0; printf("%d\n",sum); getchar(); if((c=getchar())=='#') break; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator