#include using namespace std; // ifstream in("test.in"); // ofstream out("test.out"); int main(int argc, char *argv[]) { string inName = "test.in"; string outName = "test.out"; if (argc > 1) { inName = argv[1]; cout << "Using \"" << inName << "\" for test name" << endl; } else { cout << "Warning: no in name provided, defaulting to test.in" << endl; } if (argc > 2) { outName = argv[2]; cout << "Using \"" << outName << "\" for out name" << endl; } else { cout << "Warning: no out name proviced, defaulting to test.out" << endl; } ifstream in(inName); ofstream out(outName); int n; in >> n; unordered_map numMapping; numMapping['I'] = 1; numMapping['V'] = 5; numMapping['X'] = 10; numMapping['L'] = 50; numMapping['C'] = 100; numMapping['D'] = 500; numMapping['M'] = 1000; char tmpRoman; out << n << endl; for (int i = 0; i < n; i++) { in >> tmpRoman; out << numMapping[tmpRoman] << endl; // if (!tmpRoman.size()) { // out << "0" << endl; // continue; // } // int total = 0; // int checkpoint = numMapping[tmpRoman[0]]; // int stretchTotal = 0; // for (int j = 0; j < tmpRoman.size(); j++) { // int charDex = numMapping[tmpRoman[j]]; // if (charDex == checkpoint) { // stretchTotal += charDex; // } else if (charDex > checkpoint) { // total += charDex - stretchTotal; // checkpoint = charDex; // stretchTotal = 0; // } else { // total += stretchTotal; // checkpoint = charDex; // stretchTotal = charDex; // } // } // total += stretchTotal; // // cout << total << endl; // out << total << endl; } return 0; }