fork(1) download
  1. function inclineWord($number)
  2. {
  3. $word1 = "рубль";
  4. $word2 = "рубля";
  5. $word5 = "рублей";
  6. $number = $number % 10;
  7. $arrWord1 = array(1);
  8. $arrWord2 = array(2,3,4);
  9. $arrWord5 = array(5,6,7,8,9);
  10. foreach ($arrWord1 as $arr1) {
  11. if ($number == $arr1) {
  12. return $word1;
  13. }
  14. }
  15. foreach ($arrWord2 as $arr2) {
  16. if ($number == $arr2) {
  17. return $word2;
  18. }
  19. }
  20. foreach ($arrWord5 as $arr5) {
  21. if ($number == $arr5) {
  22. return $word5;
  23. }
  24. else {
  25. $number = $number % 100;
  26. }
  27. }
  28.  
  29.  
  30. $arrWord1 = array(21, 31, 41, 51, 61, 71, 81, 91);
  31. $arrWord2 = array(22, 23, 24, 32, 33, 34, 42, 43, 44, 52, 53, 54, 62, 63, 64, 72, 73, 74, 82, 83, 84, 92, 93, 94);
  32. $arrWord5 = array(10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26, 27, 28, 29, 30, 35, 36, 37, 38, 39, 40, 45, 46, 47, 48, 49, 50, 55, 56, 57, 58, 59, 60, 65, 66, 67, 68, 69, 70, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 95, 96, 97, 98, 99);
  33.  
  34. foreach ($arrWord1 as $arr1) {
  35. if ($number == $arr1) {
  36. return $word1;
  37. }
  38. }
  39. foreach ($arrWord2 as $arr2) {
  40. if ($number == $arr2) {
  41. return $word2;
  42. }
  43. }
  44. foreach ($arrWord5 as $arr5) {
  45. if ($number == $arr5) {
  46. return $word5;
  47. }
  48. }
  49. if ($number==0)
  50. {
  51. return $word5;
  52. }
  53. }
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
function inclineWord($number)
{
    $word1 = "рубль";
    $word2 = "рубля";
    $word5 = "рублей";
    $number = $number % 10;
    $arrWord1 = array(1);
    $arrWord2 = array(2,3,4);
    $arrWord5 = array(5,6,7,8,9);
    foreach ($arrWord1 as $arr1) {
        if ($number == $arr1) {
            return $word1;
        }
    }
    foreach ($arrWord2 as $arr2) {
        if ($number == $arr2) {
            return $word2;
        }
    }
    foreach ($arrWord5 as $arr5) {
        if ($number == $arr5) {
            return $word5;
        }
        else {
            $number = $number % 100;
        }
    }


    $arrWord1 = array(21, 31, 41, 51, 61, 71, 81, 91);
    $arrWord2 = array(22, 23, 24, 32, 33, 34, 42, 43, 44, 52, 53, 54, 62, 63, 64, 72, 73, 74, 82, 83, 84, 92, 93, 94);
    $arrWord5 = array(10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26, 27, 28, 29, 30, 35, 36, 37, 38, 39, 40, 45, 46, 47, 48, 49, 50, 55, 56, 57, 58, 59, 60, 65, 66, 67, 68, 69, 70, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 95, 96, 97, 98, 99);

    foreach ($arrWord1 as $arr1) {
        if ($number == $arr1) {
            return $word1;
        }
    }
    foreach ($arrWord2 as $arr2) {
        if ($number == $arr2) {
            return $word2;
        }
    }
    foreach ($arrWord5 as $arr5) {
        if ($number == $arr5) {
            return $word5;
        }
    }
    if ($number==0)
    {
        return $word5;
    }
}