Contest 2:Temperature Conversion
来源:互联网 发布:汽车导航软件安装 编辑:程序博客网 时间:2024/06/15 01:38
Description
Fahrenheit(F) and Centigrade(C) are used as unit of measuring the temperature. The conversion between them is: F = 32 + C*1.8; C = (F - 32)/1.8
We need you write a C program to convert temperature value under different unit.
Input
The input consists of n+1 lines.
There is one integer n which is the number of test cases in the first line.
From 2nd to last line, there are a char and a float number in each line, which represent the type and temperature value. Two elements are seperated by a space. A 'C' represent the Centigrade temperature and an 'F' for Fahrenheit temperature. You need convert Centigrade temperature to Fahrenheit temperature, vice versa.
Output
The ounput consists of n lines. Each contains a float value which is converted result. No return charactor for the last line.
The float value should retain 2 digits after the decimal point.
here is a sample,
input:
2
C 10.30
F 90.41
output:
50.54
32.45
Because
C->F: 32+10.3*1.8 = 50.54
F->C: (90.41-32)/1.8 = 32.45
Sample Input
2C 10.30F 90.41
Sample Output
50.5432.45
HINT
#include <stdio.h>#include <stdlib.h>int main() { char ch; int n,i; scanf("%d\n",&n); float a[n]; for(i=1;i<=n;i++){ scanf("\n%c%f",&ch,&a[i]); int b=ch; if(b==67) a[i]=32+a[i]*1.8; else if(b==70) a[i]= (a[i]-32)/1.8;} for(i=1;i<=n;i++){ printf("%.2f\n",a[i]);} return 0;}
阅读全文
0 0
- Contest 2:Temperature Conversion
- assignment 2 - temperature converter
- Temperature
- Java源码-温度转换小程序(Temperature Conversion)
- 习题1-2 温度(temperature)
- 算法竞赛入门经典 习题1-2 温度(temperature)
- Temperature compensation
- Rising Temperature
- Rising Temperature
- LeetCode_Mysql_Rising Temperature
- Rising Temperature
- Rising Temperature
- bzoj2276 Temperature
- Rising Temperature
- Rising Temperature
- Conversion
- leetcode(2)6. ZigZag Conversion
- hdu 3477 Temperature
- iPhoneX适配解决iPhoneX跳转页面时tabbar上移问题
- 如何在Kubernetes上玩转TensorFlow ?
- HDOJ1160(最长子序列+路径追踪(并查集))
- idea部署项目com.intellij.javaee.oss.admin.jmx.JmxAdminException-未使用最新版本的war包
- 新建一个IOS工程步骤
- Contest 2:Temperature Conversion
- 【技术详解】SequoiaDB数据分区简介
- MethodReplacer替换方法实例
- 图像匹配 一些基本算法
- 解android的Handler之谜
- java向上转型和向下转型
- 原子操作
- jvm概念梳理
- (六)MapReduce特点