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可以转换相关联的类,可以从子类转换成父类.也能从父类转向子类,但是如果转换的父类指针(或者父类引用)所指向的对象是完整的,那么是没有问题:但是 ...
随机推荐
- 【转】玩转log4j
原文链接:http://www.cnblogs.com/shenliang123/archive/2012/05/02/2479286.html 由于最近正在扩展卫生局考务系统,由于上一次使用过一次该 ...
- 读取proc信息的可扩展实现
需求 1. 将内存.线程数等信息注册到zk上进行监控 2. 统计信息,为下一步做负载均衡做准备. 实现 本文只解决问题1. 从网上查询了下,这些信息可以从proc文件系统中获取,如果不知道proc的, ...
- 陕西中际现代:基于自适应算法的PLC滴灌控制系统
基于自适应算法的PLC滴灌控制系统 陕西中际现代包装科技有限公司滴灌部 1.介绍 水资源正在成为一种珍贵的资源.城镇的市民使用成千上万立方的水来浇灌花园和绿地.他们依赖于使用固定灌溉计划的控制器.而这 ...
- VS2010编译器下针对C#和C++的opencv的配置方法
我们大家都知道opencv是针对C.C++编写的,没有独立的编译调试工具.所以今天就捣鼓了一下在xp vs2010下配置C++和C#环境下的opencv.请大家一步一步的按步骤操作.本人亲自鉴定可行. ...
- android进度条的使用
// 导入按钮事件 btnsearch.setOnClickListener(new View.OnClickListener() { @Override public void on ...
- 解决ie6不支持position: fixed;导致无法滚动的办法
<div id="im" style="top: 100px; position: fixed; left: 5px; border: 3px solid #006 ...
- urlrewritingnet 域名http状态302 问题(转)
UrlRewritingNet is an Url rewriting tool for ASP .Net and Elmahis a module for logging unhandled err ...
- MES总结:CBF.Common 文件Net下的有类型转换
MES总结:CBF.Common 文件Net下的有类型转换. using System.Text;using System.Data;using System.ComponentModel;using ...
- 利用C#实现对excel的写操作
一.COM interop 首先我们要了解下何为COM Interop,它是一种服务,可以使.NET Framework对象能够与COM对象通信.Visual Studio .NET 通过引入面向公共 ...
- css3 过度效果之物体向上冒出
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"/> <meta nam ...