Sicily 1511. Conversions
来源:互联网 发布:免费下载源码的网站 编辑:程序博客网 时间:2024/06/09 20:37
Conversion between the metric and English measurement systems is relatively simple. Often, it involves either multiplying or dividing by a constant. You must write a program that converts between the following units:
The first line of input contains a single integer N , (1≤N≤1000) which is the number of datasets that follow.
Each dataset consists of a single line of input containing a floating point (double precision) number, a space and the unit specification for the measurement to be converted. The unit specification is one of kg, lb, l, or g referring to kilograms, pounds, liters and gallons respectively.
For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, and the appropriately converted value rounded to 4 decimal places, a space and the unit specification for the converted value.
5 1 kg 2 l 7 lb 3.5 g 0 l
1 2.2046 lb 2 0.5284 g 3 3.1752 kg 4 13.2489 l 5 0.0000 g
Problem Source: Greater New York 2007
// Problem#: 1511// Submission#: 3685288// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include<iostream>#include<iomanip>#include<string>using namespace std;int main(){ int n; cin>>n; int i=1; while(n--){ //int i=1; double a; string b; cin>>a>>b; if(b=="kg"){ cout<<i<<" "<<fixed<<setprecision(4)<<a*2.2046<<" lb"<<endl; } else if(b=="l"){ cout<<i<<" "<<fixed<<setprecision(4)<<a*0.2642<<" g"<<endl; } else if(b=="lb"){ cout<<i<<" "<<fixed<<setprecision(4)<<a*0.4536<<" kg"<<endl; } else if(b=="g"){ cout<<i<<" "<<fixed<<setprecision(4)<<a*3.7854<<" l"<<endl; } i++; } return 0;}
- Sicily 1511. Conversions
- 13. Conversions
- 6.3 Conversions
- zoj2988--------------Conversions
- HDU1985:Conversions
- Conversions 1985
- 3005. Conversions
- zoj2988 Conversions
- Implicit conversions
- Color conversions
- HDOJ1985 Conversions
- 8.2.2 Conversions
- 13.1 Implicit conversions
- 13.2 Explicit conversions
- 13.3 Standard conversions
- 13.4 User-defined conversions
- Item 39. Automatic Conversions
- User-defined conversions
- 项目启动的时候出现端口8080被占用
- UIKeyCommand自定义键盘
- 网站优化相关理论概述
- IOS合并lib(.a)库的终极可用方法(可用于解决duplicate symbol静态库冲突)
- UCOS + LWIP + USB WIFI(rtl8188eu) <三>
- Sicily 1511. Conversions
- 基础复习
- Activity之间互传基本数据类型
- 先学习搭建个架子:Eclipse java EE版 + S2SH + Oracle11g + Plsql.(1)
- Spring对Hibernate事务管理
- 具有“高薪缘”的行业和职位发布
- Cocoapods使用
- 数值计算
- 配置Apache