Skip to content
This repository was archived by the owner on Sep 6, 2018. It is now read-only.
12 changes: 6 additions & 6 deletions src/lesson1/task1/Simple.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun main(args: Array<String>) {
* Пользователь задает время в часах, минутах и секундах, например, 8:20:35.
* Рассчитать время в секундах, прошедшее с начала суток (30035 в данном случае).
*/
fun seconds(hours: Int, minutes: Int, seconds: Int): Int = TODO()
fun seconds(hours: Int, minutes: Int, seconds: Int): Int = (3600*hours+60*minutes+seconds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Следует придерживаться единого стиля форматирования кода во всём своём коде. Если вы ставите пробелы до и после знаков, то нужно делать это везде. Если вы этого не делаете, не делайте этого нигде.


/**
* Тривиальная
Expand All @@ -60,7 +60,7 @@ fun seconds(hours: Int, minutes: Int, seconds: Int): Int = TODO()
* Определить длину того же отрезка в метрах (в данном случае 18.98).
* 1 сажень = 3 аршина = 48 вершков, 1 вершок = 4.445 см.
*/
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double = TODO()
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double = (((sagenes*3*16*4.445)+(arshins*16*4.445)+(vershoks*4.445))/100)

/**
* Тривиальная
Expand All @@ -76,15 +76,15 @@ fun angleInRadian(grad: Int, min: Int, sec: Int): Double = TODO()
* Найти длину отрезка, соединяющего точки на плоскости с координатами (x1, y1) и (x2, y2).
* Например, расстояние между (3, 0) и (0, 4) равно 5
*/
fun trackLength(x1: Double, y1: Double, x2: Double, y2: Double): Double = TODO()
fun trackLength(x1: Double, y1: Double, x2: Double, y2: Double): Double =(sqrt(sqr(x2-x1)+sqr(y2-y1)))

/**
* Простая
*
* Пользователь задает целое число, большее 100 (например, 3801).
* Определить третью цифру справа в этом числе (в данном случае 8).
*/
fun thirdDigit(number: Int): Int = TODO()
fun thirdDigit(number: Int): Int =((number/100-(number/1000)*10))

/**
* Простая
Expand All @@ -93,7 +93,7 @@ fun thirdDigit(number: Int): Int = TODO()
* прибыл на станцию назначения в h2 часов m2 минут того же дня (например в 13:01).
* Определите время поезда в пути в минутах (в данном случае 216).
*/
fun travelMinutes(hoursDepart: Int, minutesDepart: Int, hoursArrive: Int, minutesArrive: Int): Int = TODO()
fun travelMinutes(hoursDepart: Int, minutesDepart: Int, hoursArrive: Int, minutesArrive: Int): Int =((minutesArrive+60*hoursArrive)-(minutesDepart+60*hoursDepart))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Длинные строки в коде следует разбивать на более короткие.
В данном случае следует поставить перенос строки после знака =


/**
* Простая
Expand All @@ -110,4 +110,4 @@ fun accountInThreeYears(initial: Int, percent: Int): Double = TODO()
* Пользователь задает целое трехзначное число (например, 478).
*Необходимо вывести число, полученное из заданного перестановкой цифр в обратном порядке (например, 874).
*/
fun numberRevert(number: Int): Int = TODO()
fun numberRevert(number: Int): Int =((number/100)+((number/10-(number/100*10))*10)+((number-(number/10*10))*100))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично

6 changes: 5 additions & 1 deletion src/lesson2/task2/Logical.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ fun pointInsideCircle(x: Double, y: Double, x0: Double, y0: Double, r: Double) =
* Четырехзначное число назовем счастливым, если сумма первых двух ее цифр равна сумме двух последних.
* Определить, счастливое ли заданное число, вернуть true, если это так.
*/
fun isNumberHappy(number: Int): Boolean = TODO()
fun isNumberHappy(number: Int): Boolean {
if ((number / 1000) +(number / 100 % 10) == (number % 100 / 10 + number % 10)) return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Код следует корректно форматировать посредством отступов. Обе ветки if должны быть выровнены по одному отступу.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что, по-вашему, делает операция + в выражении +(number / 100 % 10)?
Если вы не знаете, зачем нужна та или иная операция, не используйте её.

else
return false
}

/**
* Простая
Expand Down