Problem Description
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:
 
Input
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.
 
Output
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.

Sample Input
5
1 kg
2 l
7 lb
3.5 g
0 l
 
Sample Output
1 2.2046 lb
2 0.5284 g
3 3.1752 kg
4 13.2489 l
5 0.0000 g
 
 #include <stdio.h>
#include <string.h> int main(){
int T;
double amount;
char unit[];
double total;
int time; time=; scanf("%d",&T); while(T--){
scanf("%lf%s",&amount,unit); printf("%d ",time);
time++; if(strcmp(unit,"kg")==){
total=amount*2.2046; printf("%.4lf lb\n",total); } else if(strcmp(unit,"lb")==){
total=amount*0.4536; printf("%.4lf kg\n",total);
} else if(strcmp(unit,"l")==){
total=amount*0.2642; printf("%.4lf g\n",total);
} else if(strcmp(unit,"g")==){
total=amount*3.7854; printf("%.4lf l\n",total);
}
} return ;
}

Conversions的更多相关文章

  1. A Tour of Go Type conversions

    The expression T(v) converts the value v to the type T. Some numeric conversions: var i int = 42 var ...

  2. Type conversions in C++类型转换

    ###Implicit conversions隐式转换* 可以在基本类型之间自由转换:* 可以把任何类型的pointer转换为void pointer:* 可以将子类pointer转换为基类point ...

  3. [Compose] 20. Principled type conversions with Natural Transformations

    We learn what a natural transformation is and see the laws it must obey. We will see how a natural t ...

  4. JavaScript Patterns 2.8 Number Conversions with parseInt()

    Strings that start with 0 are treated as octal numbers (base 8) in ECMAScript 3; however, this has c ...

  5. HDOJ(HDU) 1985 Conversions(汇率转换)

    Problem Description Conversion between the metric and English measurement systems is relatively simp ...

  6. Chapter 5. Conversions and Promotions

    JLS解读:https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html 基本数据类型的转换 1) boolean不可以转换为其他的数据类型 ...

  7. 条款24:若所有参数皆需要类型转换,请为此采用non-member函数(Declare non-member functions when type conversions should apply to all parameters)

    NOTE: 1.如果你需要为某个函数的所有参数(包括this指针所指的那个隐喻参数)进行类型转换,那么这个函数必须是个non-member.

  8. 【参考】IBM sun.io.MalformedInputException and text encoding conversions transforms numerals to their word equivalents - United States

    Problem(Abstract) When converting contents from a file or string using WebSphere Application Server, ...

  9. C++: Type conversions

    1.static_cast     static_cast可以转换相关联的类,可以从子类转换成父类.也能从父类转向子类,但是如果转换的父类指针(或者父类引用)所指向的对象是完整的,那么是没有问题:但是 ...

随机推荐

  1. windos系统快捷键 2015-05-08 23:31 24人阅读 评论(0) 收藏

    WIN7的向上按钮消失了,但是它的快捷键没有消失: Alt + ↑: 文件夹的后退前进 Alt +← 和Alt →: 切换到上个操作的窗口Alt +Esc: 版权声明:本文为博主原创文章,未经博主允许 ...

  2. Intellij IDEA 14.x 中的Facets和Artifacts的区别

    Facets和Artifacts的区别: Facets 表示这个module有什么特征,比如 Web,Spring和Hibernate等: Artifact 是maven中的一个概念,表示某个modu ...

  3. Mac配置JAVA_HOME

    首先打开终端,输入/usr/libexec/java_home,看到 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home 说 ...

  4. PB学习笔记(一)

    前言:我绝对很痛恨PB.1.没人带2.自己摸索3.头发掉了4.老大不停的给任务5.这语言老的不行了6,代码可读性不是一般的差 我绝对很喜欢PB.1.自我学习成功后那种成就感2.老大也会帮给我看看,指点 ...

  5. sql server 复制 需要有实际的服务器名称才能连接到服务器……

    原因是:之前修改过服务器实例名称执行一下语句 select @@servername select SERVERPROPERTY ('servername') 可以看到,两个不同的结果 修改实例名称i ...

  6. Linux 下安装android

    主要参考了这篇文章 http://segmentfault.com/a/1190000003069062#articleHeader2 这里提到了“unable to run mksdcard sdk ...

  7. CMSIS Example - Mail and Timer

    #include <stdint.h> #include "bsp-fifisdr.h" #include "lpclib.h" #include ...

  8. 解决ArcGIS Android Could not find class 'com.esri.android.map.MapView'问题

    环境win7 64bit sp1,eclipse 4.2.1 ,android API 16,ADT 23.0.2,arcgis android sdk 10.2.4 从arcgis-android- ...

  9. Python 条件语句

    Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. Python程序语言指定任何非0和非空(null)值为true,0 或者 null为false. Py ...

  10. POJ 3006 Dirichlet&#39;s Theorem on Arithmetic Progressions 快筛质数

    题目大意:给出一个等差数列,问这个等差数列的第n个素数是什么. 思路:这题主要考怎样筛素数,线性筛.详见代码. CODE: #include <cstdio> #include <c ...