"카타 8급 Century From Year"의 두 판 사이의 차이

27번째 줄: 27번째 줄:
{{카타|8급|Kotlin|3}}
{{카타|8급|Kotlin|3}}
<source lang='kotlin'>
<source lang='kotlin'>
fun century(number: Int): Int {
    return (number+99)/100
}
</source>
</source>
<source lang='kotlin'>
<source lang='kotlin'>
fun century(number: Int): Int {
    return ceil(number / 100.0).toInt()
}
</source>
<source lang='kotlin'>
fun century(number: Int): Int {
    return ((number - 1) / 100).toInt() + 1
}
</source>
</source>



2019년 4월 21일 (일) 14:23 판

1 C

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

2 C++

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

3 Go

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

4 Kotlin

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

5 R

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