-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkod3_Relation patterns.cs
More file actions
38 lines (34 loc) · 991 Bytes
/
kod3_Relation patterns.cs
File metadata and controls
38 lines (34 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
namespace testing
{
internal class Program
{
/*Relational patterns
Напиши функцию, которая классифицирует температуру (double t):
< 0 → "Freezing"
0..15 → "Cold"
15..25 → "Normal"
25 → "Hot"
Верни строку.*/
static string FindTemperature(double t)
{
string result = t switch
{
< 0 => "Freezing",
>= 0 and < 15 => "Cold",
>= 15 and < 25 => "Normal",
>= 25 => "Hot",
_ => "Not temperature"
};
return result;
}
static void Main(string[] args)
{
Console.WriteLine(FindTemperature(15));
Console.WriteLine(FindTemperature(-7));
Console.WriteLine(FindTemperature(30));
}
}
}