- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 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;
}
gegMOPO4 10.12.2011 13:58 # 0
bugaga 10.12.2011 16:33 # +1
gegMOPO4 10.12.2011 22:38 # 0
Так какая причина удержит меня от установки минуса?
lucidfoxGovno 10.12.2011 23:20 # −2
По3иТив4иК
bugaga 10.12.2011 23:54 # 0
gegMOPO4 11.12.2011 00:14 # +1
Lure Of Chaos 11.12.2011 17:18 # 0
gegMOPO4 11.12.2011 19:09 # +2
lucidfoxGovno 11.12.2011 19:11 # 0
Lure Of Chaos 11.12.2011 19:47 # +1
bugaga 11.12.2011 00:51 # 0
Lure Of Chaos 11.12.2011 15:28 # 0
bugaga 11.12.2011 23:58 # 0
ctm 12.12.2011 11:12 # 0
Lure Of Chaos 12.12.2011 11:56 # 0
gegMOPO4 12.12.2011 13:14 # +1
ctm 13.12.2011 06:05 # +1
gegMOPO4 13.12.2011 13:01 # 0
Lure Of Chaos 13.12.2011 13:18 # +1
потом уже, видимо, понадобилось считать потери и раненых
ctm 13.12.2011 15:00 # 0
SmackMyBitchUp 13.12.2011 17:41 # 0
Lure Of Chaos 13.12.2011 19:33 # 0
SmackMyBitchUp 14.12.2011 18:07 # 0
Xom94ok 11.12.2011 19:51 # 0
Lure Of Chaos 11.12.2011 19:54 # 0
ctm 13.12.2011 15:04 # 0
guest8 09.04.2019 12:20 # −999