Conversions
≤ 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 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.
#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的更多相关文章
- 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 ...
- Type conversions in C++类型转换
###Implicit conversions隐式转换* 可以在基本类型之间自由转换:* 可以把任何类型的pointer转换为void pointer:* 可以将子类pointer转换为基类point ...
- [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 ...
- 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 ...
- HDOJ(HDU) 1985 Conversions(汇率转换)
Problem Description Conversion between the metric and English measurement systems is relatively simp ...
- Chapter 5. Conversions and Promotions
JLS解读:https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html 基本数据类型的转换 1) boolean不可以转换为其他的数据类型 ...
- 条款24:若所有参数皆需要类型转换,请为此采用non-member函数(Declare non-member functions when type conversions should apply to all parameters)
NOTE: 1.如果你需要为某个函数的所有参数(包括this指针所指的那个隐喻参数)进行类型转换,那么这个函数必须是个non-member.
- 【参考】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, ...
- C++: Type conversions
1.static_cast static_cast可以转换相关联的类,可以从子类转换成父类.也能从父类转向子类,但是如果转换的父类指针(或者父类引用)所指向的对象是完整的,那么是没有问题:但是 ...
随机推荐
- 转】MyEclipse使用总结——在MyEclipse中设置jsp页面为默认utf-8编码
原博文出自于:http://www.cnblogs.com/xdp-gacl/p/3496161.html 感谢! 在MyEclispe中创建Jsp页面,Jsp页面的默认编码是"ISO-88 ...
- python 遍历删除日志
#! /usr/bin/python2.6#-*- encoding:UTF-8 -*- import osimport os.pathimport time root_dir = os.getcwd ...
- 巧解Tomcat中JVM内存溢出问题
你对Tomcat 的JVM内存溢出问题的解决方法是否了解,这里和大家分享一下,相信本文介绍一定会让你有所收获. tomcat 的JVM内存溢出问题的解决 最近在熟悉一个开发了有几年的项目,需要把数据库 ...
- Codeforces 711 C. Coloring Trees (dp)
题目链接:http://codeforces.com/problemset/problem/711/C 给你n棵树,m种颜色,k是指定最后的完美值.接下来一行n个数 表示1~n树原本的颜色,0的话就是 ...
- ssh+dwr 的使用源码案例
加入dwr.jar包 ======jsp=============== <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitiona ...
- spring事物配置注意事项
<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx ...
- 26.怎样在Swift中定义宏?
Swift 中没有宏定义,苹果建议使用let 或者 get 属性来替代宏定义值.虽然没有#define,但我们仍然可以使用 #if 并配合编译的配置来完成条件编译.下面会列出Swift项目开发中的一些 ...
- extjs tablepanel 高度自适应有关问题
extjs tablepanel 高度自适应问题 项目中为了给客户好点的功能切换体验,想到了用extjs的tabpanel 在页面中用了tabpanel后,高度新打开的tab页的iframe 的高度总 ...
- How to get cocoapods work on Yosemite
查看原文:http://leancodingnow.com/how-to-get-cocoapods-work-on-yosemite/ 今天升级了Mac OS X 10.10-Yosemite以后运 ...
- mina高并发短连接导致java.io.IOException: Too many open files解决方案
http://marsvaadin.iteye.com/blog/1698924 mina性能测试 http://hi.baidu.com/rendong/item/bb5d2b0e4563c76dd ...