diff --git a/leetcode/2401-2500/2469.Convert-the-Temperature/README.md b/leetcode/2401-2500/2469.Convert-the-Temperature/README.md index 0c7801377..9c66fd10b 100755 --- a/leetcode/2401-2500/2469.Convert-the-Temperature/README.md +++ b/leetcode/2401-2500/2469.Convert-the-Temperature/README.md @@ -1,28 +1,32 @@ # [2469.Convert the Temperature][title] -> [!WARNING|style:flat] -> This question is temporarily unanswered if you have good ideas. Welcome to [Create Pull Request PR](https://github.com/kylesliu/awesome-golang-algorithm) - ## Description +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: a = "11", b = "1" -Output: "100" +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:** -### 思路1 -> ... -Convert the Temperature -```go ``` - +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. +``` ## 结语 diff --git a/leetcode/2401-2500/2469.Convert-the-Temperature/Solution.go b/leetcode/2401-2500/2469.Convert-the-Temperature/Solution.go index d115ccf5e..ee114da47 100644 --- a/leetcode/2401-2500/2469.Convert-the-Temperature/Solution.go +++ b/leetcode/2401-2500/2469.Convert-the-Temperature/Solution.go @@ -1,5 +1,5 @@ package Solution -func Solution(x bool) bool { - return x +func Solution(celsius float64) []float64 { + return []float64{celsius + 273.15, celsius*1.8 + 32.00} } diff --git a/leetcode/2401-2500/2469.Convert-the-Temperature/Solution_test.go b/leetcode/2401-2500/2469.Convert-the-Temperature/Solution_test.go index 14ff50eb4..30bb4907e 100644 --- a/leetcode/2401-2500/2469.Convert-the-Temperature/Solution_test.go +++ b/leetcode/2401-2500/2469.Convert-the-Temperature/Solution_test.go @@ -10,12 +10,11 @@ func TestSolution(t *testing.T) { // 测试用例 cases := []struct { name string - inputs bool - expect bool + inputs float64 + expect []float64 }{ - {"TestCase", true, true}, - {"TestCase", true, true}, - {"TestCase", false, false}, + {"TestCase1", 36.50, []float64{309.65000, 97.70000}}, + {"TestCase2", 122.11, []float64{395.26000, 251.79800}}, } // 开始测试 @@ -30,10 +29,10 @@ func TestSolution(t *testing.T) { } } -// 压力测试 +// 压力测试 func BenchmarkSolution(b *testing.B) { } -// 使用案列 +// 使用案列 func ExampleSolution() { }