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 ;
}

最新文章

  1. android 两种实现计时器时分秒的实现,把时间放在你的手中~
  2. BZOJ4567[Scoi2016]背单词
  3. Android代码规范----按钮单击事件的四种写法
  4. php面向对象之__toString()
  5. 使用dynamic来简化反射实现
  6. 在python中编写socket服务端模块(二):使用poll或epoll
  7. zzu--2014年11月16日月潭赛 B称号
  8. Angular5.0.0新特性
  9. Nginx安装与代理
  10. [洛谷P1438] 无聊的数列
  11. iframe和form表单实现ajax请求上传数据
  12. C#中如何把int转换成两个字符的string
  13. nginx反向代理服务器获取不到端口的问题的解决办法
  14. HibernateUtil工具类的使用
  15. 第五篇:jmeter图形监控扩展
  16. 2017-2018-2 20165318 实验四《Android程序设计》实验报告
  17. Spark记录-Scala数组
  18. apache2.2 虚拟主机配置(转)
  19. 案例:用Redis来存储关注关系
  20. linux Composer 安装

热门文章

  1. DCPcrypt
  2. Spark RDD概念学习系列之RDD的5大特点(五)
  3. 【Linux笔记】Linux目录结构
  4. kindeditor html代码过滤不能保存
  5. VC、MFC中设置控件的背景色、标题、字体颜色、字体要注意的地方[转]
  6. 本地存储(cookie&amp;sessionStorage&amp;localStorage)
  7. SiteMesh学习入门
  8. svn 冲突解决
  9. C#获取程序集的版本号和最后编译时间
  10. The J1850 Core