-
-
Save victorpavlenko/7872c5a7a167bae71563 to your computer and use it in GitHub Desktop.
ь, я, ей
This file contains 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
var forms = 'рубль,рубля,рублей'.split(',') | |
/* Алгориииитм! */ | |
function getForm(x) { | |
var x10 = x % 10, x100 = x % 100, form = 2 // рублей | |
if (x10 == 1 && x100 != 11) | |
form = 0 // рубль | |
else if (x10 > 1 && x10 < 5 && (x100 < 10 || x100 > 21)) | |
form = 1 // рубля | |
return forms[form] | |
} | |
/* Ненаучный тест */ | |
var res = '' | |
for (var i = 0; i < 26; ++i) { | |
res += i + ' ' + getForm(i) + '<br>' | |
} | |
res += '...<br>' | |
for (var i = 100; i < 126; ++i) { | |
res += i + ' ' + getForm(i) + '<br>' | |
} | |
document.getElementById('out').innerHTML = res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment