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 |
注意一下进位,看看我的代码!发个代码告诉啊! 让POJ不要再害人了啊! #include<stdio.h> #include<string.h> int main() { char s1[100],s2[100],s3[10]; int sum,n; while(1) { sum=0; while(1) { scanf("%s",s1); if(strcmp(s1,"#")==0) goto loop; if(strcmp(s1,"0")==0) break; scanf("%s %d %s",s2,&n,s3); if(strcmp(s3,"Y")==0) { if(n<=500) sum+=500; else sum+=n; } else if(strcmp(s3,"B")==0) sum+=n+(n+1)/2;//等价于sum+=1.5*n; else if(strcmp(s3,"F")==0) sum+=2*n; } printf("%d\n",sum); sum=0; } loop:; return 0; } /* Sample Input Beijing Tokyo 1329 F Shanghai Wuhan 433 Y 0 # Sample Output 3158 */ Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator