32, 33
This commit is contained in:
parent
853d0ced19
commit
5788b5df57
2 changed files with 26 additions and 2 deletions
20
src/u33.rs
20
src/u33.rs
|
@ -1 +1,19 @@
|
|||
pub fn main() {}
|
||||
pub fn main() {
|
||||
println!("Zadaj cislo a znacku (F/C)");
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let mut input = input.trim().to_string();
|
||||
let unit = input.remove(input.len() - 1);
|
||||
let num: f64 = input.parse().expect("Neda sa retazec premenit na cislo");
|
||||
match unit {
|
||||
'C' | 'c' => {
|
||||
println!("{}F", num * 1.8 + 32.0)
|
||||
}
|
||||
'F' | 'f' => {
|
||||
println!("{}C", (num - 32.0)/1.8)
|
||||
}
|
||||
_ => {
|
||||
println!("nepodporovana znacka")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue