Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int Number = 1929244;
- string Numeral;
- if (Number > 0) {
- do {
- if (Number >= 1000000) {
- Number -= 1000000;
- Numeral += "_M";
- } else if (Number >= 900000) {
- Number -= 900000;
- Numeral += "_C_M";
- } else if (Number >= 500000) {
- Number -= 500000;
- Numeral += "_D";
- } else if (Number >= 400000) {
- Number -= 400000;
- Numeral += "_C_D";
- } else if (Number >= 100000) {
- Number -= 100000;
- Numeral += "_C";
- } else if (Number >= 90000) {
- Number -= 90000;
- Numeral += "_X_C";
- } else if (Number >= 50000) {
- Number -= 50000;
- Numeral += "_L";
- } else if (Number >= 40000) {
- Number -= 40000;
- Numeral += "_X_L";
- } else if (Number >= 10000) {
- Number -= 10000;
- Numeral += "_X";
- } else if (Number >= 9000) {
- Number -= 9000;
- Numeral += "_I_X";
- } else if (Number >= 5000) {
- Number -= 5000;
- Numeral += "_V";
- } else if (Number >= 4000) {
- Number -= 4000;
- Numeral += "_IV";
- } else if (Number >= 1000) {
- Number -= 1000;
- Numeral += "M";
- } else if (Number >= 900) {
- Number -= 900;
- Numeral += "CM";
- } else if (Number >= 500) {
- Number -= 500;
- Numeral += "D";
- } else if (Number >= 400) {
- Number -= 400;
- Numeral += "CD";
- } else if (Number >= 100) {
- Number -= 100;
- Numeral += "C";
- } else if (Number >= 90) {
- Number -= 90;
- Numeral += "XC";
- } else if (Number >= 50) {
- Number -= 50;
- Numeral += "L";
- } else if (Number >= 40) {
- Number -= 40;
- Numeral += "XL";
- } else if (Number >= 10) {
- Number -= 10;
- Numeral += "X";
- } else if (Number >= 9) {
- Number -= 9;
- Numeral += "IX";
- } else if (Number >= 5) {
- Number -= 5;
- Numeral += "V";
- } else if (Number >= 4) {
- Number -= 4;
- Numeral += "IV";
- } else {
- Number -= 1;
- Numeral += "I";
- }
- } while (Number != 0);
- cout << Numeral;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement