1057 mileage bank小结
来源:互联网 发布:带移动端的开源cms 编辑:程序博客网 时间:2024/06/05 22:56
1.题目描述:
Mileage program of ACM (Airline of Charming Merlion) is really nice for the travelers flying frequently. Once you complete a flight with ACM, you can earn ACMPerk miles in your ACM Mileage Bank depended on mileage you actual fly. In addition, you can use the ACMPerk mileage in your Mileage Bank to exchange free flight ticket of ACM in future.
The following table helps you calculate how many ACMPerk miles you can earn when you fly on ACM.
1-500 miles
500+ miles
500 miles
Actual mileage
It's shown that your ACMPerk mileage consists of two parts. One is your actual flight mileage (the minimum ACMPerk mileage for Economy Class for one flight is 500 miles), the other is the mileage bonus (its accuracy is up to 1 mile) when you fly in Business Class and First Class. For example, you can earn 1329 ACMPerk miles, 1994 ACMPerk miles and 2658 ACMPerk miles for Y, B or F class respectively for the fly from Beijing to Tokyo (the actual mileage between Beijing and Tokyo is 1329 miles). When you fly from Shanghai to Wuhan, you can earn ACMPerk 500 miles for economy class and ACMPerk 650 miles for business class (the actual mileage between Shanghai and Wuhan is 433 miles).
Your task is to help ACM build a program for automatic calculation of ACMPerk mileage.
Input
The input file contains several data cases. Each case has many flight records, each per line. The flight record is in the following format:
OriginalCity DistanceCity ActualMiles ClassCode
Each case ends with a line of one zero.
A line of one # presents the end of the input file.
Output
Output the summary of ACMPerk mileages for each test case, one per line.
Sample Input
Beijing Tokyo 1329 FShanghai Wuhan 433 Y0#
Sample Output
31582.题目概述及解题思路:
很简单的一道题,记录飞行里程数,然后按照特权级别的公式算出飞行积分。决定开始试着使用结构体,确实挺好用的。还用了很不常用的switch case。
3.代码:
#include <iostream>#include <string>using namespace std;struct record{ string start; string des; int mile; char cla;};int main(){ record a; int acmile=0; while(true) { cin>>a.start; if(a.start[0]=='#') return 0; if(a.start[0]=='0') { cout<<acmile<<endl; acmile=0; continue; } cin>>a.des>>a.mile>>a.cla; switch(a.cla) { case 'F': { acmile+=2*a.mile; break; } case 'B': { if(a.mile%2==0) a.mile=a.mile*3/2; else { a.mile=a.mile*3/2+1; } acmile+=a.mile; break; } case 'Y': { if(a.mile<500) acmile+=500; else { acmile+=a.mile; } break; } } } return 0;}
- 1057 mileage bank小结
- Hoj 1057 Mileage Bank
- Mileage Bank
- Mileage Bank
- pku1326 - Mileage Bank
- FZU 1116 Mileage Bank
- POJ 1326 Mileage Bank
- poj1326(Mileage Bank)
- POJ 1326 Mileage Bank
- zoj 1365 Mileage Bank
- POJ1326浅析------Mileage Bank
- poj 1326 Mileage Bank
- ZOJ 1365 Mileage Bank
- 1326 Mileage Bank
- zoj 1365 Mileage Bank
- ZOJ 1365 mileage bank
- POJ 1326 Mileage Bank
- 题目1484:Mileage Bank
- linux修复开机出现grub rescue模式
- Android framework系统默认设置修改
- oracle 游标的使用
- Go语言源码中Replacer查找部份的笔记
- 用LinkedHashMap实现的LRU算法
- 1057 mileage bank小结
- IOS学习笔记 多线程篇(一) 概述
- android将log保存到文件
- AHB总线和APB总线
- Android 使用Scroller实现绚丽的ListView左右滑动删除Item效果
- MFC之设计工具栏
- 跟一下wpa_supplicant(1) 初始化
- mysql存储过程详解
- Android Application-Telephony-RIL 3 DialpadFragment to RIL.dial