LeetCode2469. Convert the Temperature

2024-01-03 23:04

本文主要是介绍LeetCode2469. Convert the Temperature,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

    • 一、题目
    • 二、题解

一、题目

You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius.

You should convert Celsius into Kelvin and Fahrenheit and return it as an array ans = [kelvin, fahrenheit].

Return the array ans. Answers within 10-5 of the actual answer will be accepted.

Note that:

Kelvin = Celsius + 273.15
Fahrenheit = Celsius * 1.80 + 32.00

Example 1:

Input: celsius = 36.50
Output: [309.65000,97.70000]
Explanation: Temperature at 36.50 Celsius converted in Kelvin is 309.65 and converted in Fahrenheit is 97.70.
Example 2:

Input: celsius = 122.11
Output: [395.26000,251.79800]
Explanation: Temperature at 122.11 Celsius converted in Kelvin is 395.26 and converted in Fahrenheit is 251.798.

Constraints:

0 <= celsius <= 1000

二、题解

class Solution {
public:vector<double> convertTemperature(double celsius) {return {celsius + 273.15,celsius * 1.8 + 32};}
};

这篇关于LeetCode2469. Convert the Temperature的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/567351

相关文章

org.springframework.core.convert.ConversionFailedException

适用: 1.你在springmvc.xml中写了静态资源处理<mvc:resources location="/" mapping="/**"></mvc:resources> 2.你在springmvc.xml中写了日期类型转换 解决方法: 首先检测你的spring版本,然后 1.spring3.0后将<mvc:resources location="/" mapping="/**">

ValueError: could not convert string ‘date‘ to float64 at row 0, column 1.

ValueError:无法将字符串“date”转换为第0行第1列的float64。 解决办法: 通过以下代码检查自己的数据,查找问题,逐一改正。 import csvdef find_blank_or_invalid_cells(file_path):blank_cells = []invalid_cells = []with open(file_path, 'r', newline=

wstring_convert

char*和wchar_t*之间的相互转换。 W2A及A2W 要点: - USES_CONVERSION; - W2A及A2W - 只能用在c++代码中。 代码: #include wstring_convert 参考: http://www.cplusplus.com/reference/locale/wstring_convert/ 最新的C++编译器才行。 该链接中的

ptr.inl.hpp:121:13: error: cannot convert ‘const char*’ to ‘cv::Formatted*’ in initialization

opencv 里面定义了 print()函数 。如果在写C++时候,将printf 写成了print就会报这个错误。

leetcode 刷题之路 14 Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目要求将有序数组转换为一个二元查找树。树的题目大部分都可以采用递归来解决,这道题也不例外。一个二元查找树的左子树上的所有节点都小于根节点,右子树上的所有节点都大于根节点,同时二元查找树左子树和右子树上

Leetcode143: Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 与排序好的数组转化为二分搜索树的题相似,可以先把链表转化为数组在转化为树。 /*** Definition for singly-linked list.* struct

PPT到PDF转换器:一个功能强大的Python GUI应用(unzip,convert,replace,merge)

在当今的数字时代,文档格式转换已成为一项常见需求。特别是将PowerPoint演示文稿转换为PDF格式,这不仅可以确保文档的一致性,还能方便分享和打印。今天,我们将深入探讨一个使用Python开发的强大GUI应用程序,它不仅可以将PPT转换为PDF,还具备文本替换、PDF处理和文件合并等多项功能。 C:\pythoncode\new\unzipconvertpdfmerge.py 应用概述 这

PIL convert(‘RGB‘) 用法

PIL 不提供 BGR转RGB的方法。 1. 图像模式转换 如果图像当前的模式不是 RGB,例如它是灰度(L)、CMYK 或其他模式时,convert('RGB') 会将图像转换为 RGB 格式。 灰度图像 (L): 如果图像是灰度图像 (L),convert('RGB') 会将其转换为 RGB 模式。每个灰度值会复制到红、绿、蓝三个通道上。 img = Image.open("gra

SQL Server 查询语句中,对索引列做CONVERT的影响

通常,在做SQL Server查询语句优化的时候,如果发现语句对索引列做了函数计算,都会建议改写,将计算的逻辑转移到筛选条件列上。但这种对索引列的计算,有时却会带来一些额外的好处。请看以下的例子: --测试数据库 adventureworks2022,兼容级别160--创建如下的索引:USE AdventureWorks2022goCREATE NONCLUSTERED

使用try-convert将.NET Framework项目迁移到.NET Core

try-convert 是一个命令行工具,它可以帮助开发者将 .NET Framework 项目迁移到 .NET Core 或 .NET 5/6/7(以及更高版本,取决于发布时的最新版本)。这是 Microsoft 官方提供的一个工具,旨在简化迁移过程,但请注意,它不会自动解决所有兼容性问题,因为它主要是帮助进行项目文件和配置文件的转换。 以下是将 .NET Framework 项目迁移到 .N