1120(toj)
来源:互联网 发布:深圳cnc数控编程培训 编辑:程序博客网 时间:2024/05/16 14:15
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 7427 Accepted Runs: 2390
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
3158
第一次ACM作业留的题,因为觉得的挺难,从网上借鉴了很多。
第一次用用strcmp函数比较两个字符串。如果两个字符串相等,则返回值为0,如果过不相等,则返回值为1。
这道题现在看起来还是挺简单的。
#include <iostream>#include <string.h>#include <stdio.h>#undef strcmpusing namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { char city[20]; char country[20]; char tag[1]; int mile; int totalInstant=0; cin>>city; while (strcmp(city,"#")) { while (strcmp(city,"0")) { cin>>country>>mile>>tag;if (strcmp(tag,"F")==0) totalInstant += mile*2; else if (strcmp(tag,"B")==0) totalInstant +=mile *1.5; else if (strcmp(tag,"Y")==0) totalInstant +=mile>500?mile:500;//如果mile > 500,那么总数加上mile就ok。如果小于500 ,则加上500 cin>>city; //if (strcmp(city,"0")==0) break; } cout <<totalInstant<<endl; totalInstant = 0; cin>>city; //if (strcmp(city,"#")==0) break; } //cout <<totalInstant<<endl; return 0;}
- 1120(toj)
- TOJ 2976
- toj 3140
- toj 1153
- TOJ 1772
- TOJ 3250
- TOJ 3051
- TOJ 4303
- TOJ 1005
- TOJ 1545
- TOJ 2378
- TOJ 1537
- TOJ 1252
- TOJ 1408
- TOJ 1509
- TOJ 2882
- TOJ 1052
- TOJ-ACM
- 从我的第三份工作开始,认真的钻研技术
- MVC设计模式
- Leaflet介绍
- 初始化SpringBoot的四种方法
- Java单例模式1.0
- 1120(toj)
- TensorFlow学习笔记2:基本运算
- CSS样式规则语法
- [JSP]javabeans/与JavaBean相关的动作元素
- Java的继承
- python3解决解压zip文件是文件名乱码问题
- Struts2
- Fast Approximate Energy Minimization via Graph Cuts
- 排序算法——冒泡排序