markdown C# - JS - Python - 算法:从一年开始的世纪

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown C# - JS - Python - 算法:从一年开始的世纪相关的知识,希望对你有一定的参考价值。

int centuryFromYear(int year) {
    return 1 + (year-1)/100;
}
function centuryFromYear(year) {
    return 1 + Math.floor((year-1)/100)
}
def centuryFromYear(year):
    # // -> Floor division - division that results into whole number adjusted to the left in the number line. Example: 15//4 = 3
    return 1 + (year - 1) // 100
# Description:
Given a year, return the century it is in. 
The first century spans from the year 1 up to and including the year 100, 
the second - from the year 101 up to and including the year 200, etc.

以上是关于markdown C# - JS - Python - 算法:从一年开始的世纪的主要内容,如果未能解决你的问题,请参考以下文章