Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- string C[MAXR] = {"I", "V", "X", "L", "C", "D", "M"};
- int X[MAXR] = {1, 5, 10, 50, 100, 500, 1000};
- ...
- R.clear();
- for (int i = 0; i < MAXR; i++)
- R.push_back(make_pair(X[i], C[i]));
- for (int i = 0; i < MAXR; i += 2)
- for (int j = i + 1; j < i + 3 && j < MAXR; j++)
- R.push_back(make_pair(X[j] - X[i], C[i] + C[j]));
- sort(R.rbegin(), R.rend());
- for (int i = 0; i < (int)R.size(); i++)
- {
- for (int j = 0; j < x / R[i].first; j++)
- cout << R[i].second;
- x %= R[i].first;
- }
- cout << endl;
- ...
Add Comment
Please, Sign In to add comment