1. Список говнокодов пользователя bugaga

    Всего: 1

  2. C++ / Говнокод #8788

    +1006

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    const unsigned BAD_VALUE = (unsigned) -1;
    typedef pair<string, unsigned> RomeDecPair;
    typedef map<string, unsigned> Table;
    Table g_table;
     
    void InitTables()
    {
      g_table["I"] = 1;
      g_table["II"] = 2;
      g_table["III"] = 3;
      g_table["IV"] = 4;
      g_table["V"] = 5;
      g_table["VI"] = 6;
      g_table["VII"] = 7;
      g_table["VIII"] = 8;
      g_table["IX"] = 9;
      g_table["X"] = 10;
      g_table["XX"] = 20;
      g_table["XXX"] = 30;
      g_table["XL"] = 40;
      g_table["L"] = 50;
      g_table["XC"] = 90;
      g_table["C"] = 100;
      g_table["CC"] = 200;
      g_table["CCC"] = 300;
      g_table["CD"] = 400;
      g_table["D"] = 500;
      g_table["CM"] = 900;
      g_table["M"] = 1000;
      g_table["MM"] = 2000;
      g_table["MMM"] = 3000;
    }
    .....
    int main()
    {
      InitTables();
     
      vector<RomeDecPair> tests;
     
      tests.push_back(make_pair("I", 1));
      tests.push_back(make_pair("II", 2));
      tests.push_back(make_pair("III", 3));
      tests.push_back(make_pair("IV", 4));
      tests.push_back(make_pair("V", 5));
      tests.push_back(make_pair("VI", 6));
      tests.push_back(make_pair("VII", 7));
      tests.push_back(make_pair("VIII", 8));
      tests.push_back(make_pair("IX", 9));
      tests.push_back(make_pair("X", 10));
      tests.push_back(make_pair("XI", 11));
      tests.push_back(make_pair("XII", 12));
      tests.push_back(make_pair("XIII", 13));
      tests.push_back(make_pair("XIV", 14));
      tests.push_back(make_pair("XV", 15));
      tests.push_back(make_pair("XVI", 16));
      tests.push_back(make_pair("XVII", 17));
      tests.push_back(make_pair("XVIII", 18));
      tests.push_back(make_pair("XIX", 19));
      tests.push_back(make_pair("XX", 20));
      tests.push_back(make_pair("XXI", 21));
      tests.push_back(make_pair("XL", 40));
      tests.push_back(make_pair("XLII", 42));
      tests.push_back(make_pair("LIX", 59));
      tests.push_back(make_pair("LXXVII", 77));
      tests.push_back(make_pair("XC", 90));
      tests.push_back(make_pair("CX", 110));
      tests.push_back(make_pair("CDXCIX", 499));
      tests.push_back(make_pair("DLXXXIII", 583));
      tests.push_back(make_pair("DCCCLXXXVIII", 888));
      tests.push_back(make_pair("MDCLXVIII", 1668));
      tests.push_back(make_pair("MCMLXXXIX", 1989));
      tests.push_back(make_pair("MMMCMXCIX", 3999));
     
      tests.push_back(make_pair("", BAD_VALUE));
      tests.push_back(make_pair("IIIV", BAD_VALUE));
      tests.push_back(make_pair("IIV", BAD_VALUE));
      tests.push_back(make_pair("IIII", BAD_VALUE));
      tests.push_back(make_pair("IIX", BAD_VALUE));
      tests.push_back(make_pair("XIIII", BAD_VALUE));
      tests.push_back(make_pair("XIIIIX", BAD_VALUE));
      tests.push_back(make_pair("XIIIIX", BAD_VALUE));
      tests.push_back(make_pair("XXXX", BAD_VALUE));
      tests.push_back(make_pair("LL", BAD_VALUE));
      tests.push_back(make_pair("CLC", BAD_VALUE));
      tests.push_back(make_pair("CLL", BAD_VALUE));
      tests.push_back(make_pair("DLD", BAD_VALUE));
      tests.push_back(make_pair("LDD", BAD_VALUE));
      tests.push_back(make_pair("LLI", BAD_VALUE));
      tests.push_back(make_pair("MMMCMXCX", BAD_VALUE));
      tests.push_back(make_pair("AXX", BAD_VALUE));
      tests.push_back(make_pair("LXA", BAD_VALUE));
     
      for (vector<RomeDecPair>::const_iterator it = tests.begin(), end = tests.end(); it != end; ++it)
      {
        CheckConversion(*it);
      }
     
      return 0;
    }

    bugaga, 10 Декабря 2011

    Комментарии (27)