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

请高人帮我该该。

Posted by dangfeng at 2009-01-03 12:27:17 on Problem 1326
#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:
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