Решение на упр.01 задача 2 от Деян Делчев
Резултати
- 1 точка от тестове
- 0 бонус точки
- 1 точка общо
- 1 успешни тест(а)
- 0 неуспешни тест(а)
Код
fn check_triangle(a: i32, b: i32, c: i32) -> &'static str {
let shortest = std::cmp::min(std::cmp::min(a, b), c);
let longest = std::cmp::max(std::cmp::max(a, b), c);
let middle = a + b + c - shortest - longest;
if shortest <= 0 {
return "невалидни страни";
}
if shortest + middle <= longest {
return "не е триъгълник";
}
if shortest == longest {
return "равностранен";
}
if shortest == middle || longest == middle {
return "равнобедрен";
}
return "разностранен";
}
Лог от изпълнението
Updating crates.io index
Locking 17 packages to latest compatible versions
Compiling proc-macro2 v1.0.101
Compiling unicode-ident v1.0.19
Compiling quote v1.0.41
Compiling futures-sink v0.3.31
Compiling futures-core v0.3.31
Compiling futures-channel v0.3.31
Compiling futures-io v0.3.31
Compiling futures-task v0.3.31
Compiling syn v2.0.106
Compiling memchr v2.7.6
Compiling pin-project-lite v0.2.16
Compiling pin-utils v0.1.0
Compiling slab v0.4.11
Compiling solution v0.1.0 (/tmp/d20251016-574132-1sl2d0n/solution)
warning: function `check_triangle` is never used
--> src/lib.rs:1:4
|
1 | fn check_triangle(a: i32, b: i32, c: i32) -> &'static str {
| ^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: `solution` (lib) generated 1 warning
Compiling futures-macro v0.3.31
Compiling futures-util v0.3.31
Compiling futures-executor v0.3.31
Compiling futures v0.3.31
Finished `test` profile [unoptimized + debuginfo] target(s) in 8.19s
Running tests/solution_test.rs (target/debug/deps/solution_test-80bf62783e3de781)
running 1 test
test solution_test::test_basic ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
