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. cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案

    原文地址 : http://www.cnblogs.com/hhuang2012/p/3336911.html cocos2dx android版本移植时的Error format not a str ...

  2. shell输出调试信息

    [shell输出调试信息] 1.使用trap命令 trap命令用于捕获指定的信号并执行预定义的命令. 其基本的语法是: trap 'command' signal 其中signal是要捕获的信号,co ...

  3. Python序列(Sequence)

    Sequence是Python的一种内置类型(built-in type),内置类型就是构建在Python Interpreter里面的类型,三种基本的Sequence Type是list(表),tu ...

  4. Codeforces 597C. Subsequences (树状数组+dp)

    题目链接:http://codeforces.com/contest/597/problem/C 给你n和数(1~n各不同),问你长为k+1的上升自序列有多少. dp[i][j] 表示末尾数字为i 长 ...

  5. HDU 5706 GirlCat (DFS,暴力)

    题意:给定一个n*m的矩阵,然后问你里面存在“girl”和“cat”的数量. 析:很简单么,就是普通搜索DFS,很少量.只要每一个字符对上就好,否则就结束. 代码如下: #include <cs ...

  6. android 小方法

    小方法 1.获取屏幕分辨率: public class BaseTools { public static int getWindowWidth(Context context) { // 获取屏幕分 ...

  7. android ListView中button点击事件盖掉onItemClick解决办法

    ListView 1.在android应用当中,很多时候都要用到listView,但如果ListView当中添加Button后,ListView 自己的 public void onItemClick ...

  8. hibernate的配置文件

  9. javascript之冒泡算法

    今天看了js中数组的方法,其中sort()方法用于排序,就让我想到学C语言的时候有一个冒泡算法,就想用js写一个. <script> var arr=[1,30,20,40,21,31,1 ...

  10. 汽车常用的ECU芯片

    Power Train ECU的CPU用的比较多的基本来自于Infineon,ST,Freescale BOSCH的16位ECU M(E)7系列主要使用C167内核的CPU,早期的M(E)7系列使用西 ...