Решение на упр.01 задача 2 от Петя Петрова

Обратно към всички решения

Към профила на Петя Петрова

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 1 успешни тест(а)
  • 0 неуспешни тест(а)

Код

fn check_triangle(a: i32, b: i32, c:i32) -> &'static str
{
if a <= 0 || b <= 0 || c <= 0
{
"невалидни страни"
}
else
{
let sumAB = a + b;
let sumAC = a + c;
let sumBC = b + c;
if sumAB <= c || sumAC <= b || sumBC <= a
{
"не е триъгълник"
}
else if a == b && b == c
{
"равностранен"
}
else if a == b || b == c || a == c
{
"равнобедрен"
}
else
{
"разностранен"
}
}
}

Лог от изпълнението

Updating crates.io index
     Locking 17 packages to latest compatible versions
   Compiling proc-macro2 v1.0.101
   Compiling quote v1.0.41
   Compiling unicode-ident v1.0.19
   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 slab v0.4.11
   Compiling futures-task v0.3.31
   Compiling syn v2.0.106
   Compiling pin-project-lite v0.2.16
   Compiling pin-utils v0.1.0
   Compiling memchr v2.7.6
   Compiling solution v0.1.0 (/tmp/d20251016-574132-1a6rgx1/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: variable `sumAB` should have a snake case name
 --> src/lib.rs:9:13
  |
9 |         let sumAB = a + b;
  |             ^^^^^ help: convert the identifier to snake case: `sum_ab`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: variable `sumAC` should have a snake case name
  --> src/lib.rs:10:13
   |
10 |         let sumAC = a + c;
   |             ^^^^^ help: convert the identifier to snake case: `sum_ac`

warning: variable `sumBC` should have a snake case name
  --> src/lib.rs:11:13
   |
11 |         let sumBC = b + c;
   |             ^^^^^ help: convert the identifier to snake case: `sum_bc`

warning: `solution` (lib) generated 4 warnings
   Compiling futures-macro v0.3.31
   Compiling futures-util v0.3.31
   Compiling futures-executor v0.3.31
   Compiling futures v0.3.31
warning: variable `sumAB` should have a snake case name
 --> tests/../src/lib.rs:9:13
  |
9 |         let sumAB = a + b;
  |             ^^^^^ help: convert the identifier to snake case: `sum_ab`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: variable `sumAC` should have a snake case name
  --> tests/../src/lib.rs:10:13
   |
10 |         let sumAC = a + c;
   |             ^^^^^ help: convert the identifier to snake case: `sum_ac`

warning: variable `sumBC` should have a snake case name
  --> tests/../src/lib.rs:11:13
   |
11 |         let sumBC = b + c;
   |             ^^^^^ help: convert the identifier to snake case: `sum_bc`

warning: `solution` (test "solution_test") generated 3 warnings
    Finished `test` profile [unoptimized + debuginfo] target(s) in 7.71s
     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

История (2 версии и 0 коментара)

Петя качи първо решение на 09.10.2025 19:40 (преди 21 дена)

Петя качи решение на 09.10.2025 19:47 (преди 21 дена)

fn check_triangle(a: i32, b: i32, c:i32) -> &'static str
{
- if a < 0 || b < 0 || c < 0
+ if a <= 0 || b <= 0 || c <= 0
{
"невалидни страни"
}
else
{
let sumAB = a + b;
let sumAC = a + c;
let sumBC = b + c;
if sumAB <= c || sumAC <= b || sumBC <= a
{
"не е триъгълник"
}
else if a == b && b == c
{
"равностранен"
}
else if a == b || b == c || a == c
{
"равнобедрен"
}
else
{
"разностранен"
}
}
}