smlstlmnt

package
v0.0.0-...-4995c53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: MIT Imports: 0 Imported by: 0

README

Завдання

Знайдіть помилку (помилки) та змініть один рядок коду в неправильній реалізації функції, яка повинна повертати найменший елемент даного непорожнього масиву Array, який містить щонайбільше 1000 цілих чисел у діапазоні [-1000..1000 ]. Зверніть увагу, що для прикладу тесту Array = [-1, 1, -2, 2] доданий код вже повертає правильну відповідь (-2).

Реалізація функціі

package smlstlmnt

// SmallestElement returns integer
func SmallestElement(Array []int) int {
  var result int = 0
  for i := 1; i < len(Array); i++ {
    if result > Array[i] {
      result = Array[i]
    }
  }
  return result
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SmallestElement

func SmallestElement(Array []int) int

SmallestElement returns integer

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL