This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static int binarySearch(int[] sortedArray, int key, int low, int high) { | |
| // считаем индекс центрального элемента | |
| int middle = low + (high - low) / 2; | |
| // base case (условие выхода) - регион поиска пустой | |
| if (low > high) { | |
| // не нашли элемента, который равен ключу | |
| return -1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1 | |
| def convert(miles): | |
| return miles * 1.609 | |
| # 2 | |
| def area(a, b): | |
| return a * b | |
| # 3 (первый вариант - с использованием if) | |
| def is_even(a): |
NewerOlder