16.03.2013, 06:31
(
Last edited by Richard_Gere; 16/03/2013 at 07:21 AM.
)
Склонение существительных с числительными
Источник: http://habrahabr.ru/post/37579/
pawn Code:
stock abs(value) return ((value < 0 ) ? (-value) : (value));
stock pluralForm(n, form1[], form2[], form5[], output[], size)
{
n = abs(n) % 100;
new n1 = n % 10;
if (10 < n < 20) return format(output, size, form5);
if (1 < n1 < 5) return format(output, size, form2);
if (n1 == 1) return format(output, size, form1);
return format(output, size, form5);
}
//Пример
new textpatr[10];
pluralForm(24, "патрон", "патрона", "патронов", textpatr, sizeof(textpatr)); // патрона
pluralForm(25, "патрон", "патрона", "патронов", textpatr, sizeof(textpatr)); // патронов
pluralForm(21, "патрон", "патрона", "патронов", textpatr, sizeof(textpatr)); // патрон