카타 8급 Century From Year

Jmnote (토론 | 기여)님의 2019년 4월 21일 (일) 14:23 판 (→‎Kotlin)

1 C

int centuryFromYear(int year) {
  return (year+99)/100;
}

2 C++

int centuryFromYear(int year) 
{
  return (year+99)/100;
}

3 Go

package kata
func century(year int) int {
  return (year+99)/100;
}

4 Kotlin

fun century(number: Int): Int {
    return (number+99)/100
}
fun century(number: Int): Int {
    return ceil(number / 100.0).toInt()
}
fun century(number: Int): Int {
    return ((number - 1) / 100).toInt() + 1
}

5 R

century <- function(year) {
  (year+99) %/% 100
}