1 2 3 4 5 6 7 8 9 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
// roman_numeral.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
#include<math.h>
#include <ctype.h>
#include <cctype>
#include <functional>
using namespace std;
int main()
{
int x=0,i=0,n=0,w=0,e=0,q=0, start=0;
string nothing = "";
string imverytired = "";
string nothealthytired = "mdclxvi";
string roman = "MDCLXVI";
string p = "What would you like to start with? <1-5000>";
string o = "that number is not in the range of 1-5000.";
cout << "what would you like to start with? <1-5000>" ;
cin >> start;
while(start<1||start>5000)
{
cout<<"that number is not in the range of 1-5000.";
cout<< "what would you like to start with? <1-5000>";
cin >> start;
}
//..............................UPPER CASE................................
for(i=start;i<=start+20;i++)
{
x=i;
n=x/1000;
nothing.append(n,roman[0]);
x=x%1000;
n=x/500;
nothing.append(n,roman[1]);
x=x%500;
n=x/100;
nothing.append(n,roman[2]);
x=x%100;
n=x/50;
nothing.append(n,roman[3]);
x=x%50;
n=x/10;
nothing.append(n,roman[4]);
x=x%10;
n=x/5;
nothing.append(n,roman[5]);
x=x%5;
n=x/1;
nothing.append(n,roman[6]);
x=x%1;
//..............................................................................
//..................................lower case...............................
w=i;
q=w/1000;
imverytired.append(q,nothealthytired[0]);
w=w%1000;
q=w/500;
imverytired.append(q,nothealthytired[1]);
w=w%500;
q=w/100;
imverytired.append(q,nothealthytired[2]);
w=w%100;
q=w/50;
imverytired.append(q,nothealthytired[3]);
w=w%50;
q=w/10;
imverytired.append(q,nothealthytired[4]);
w=w%10;
q=w/5;
imverytired.append(q,nothealthytired[5]);
w=w%5;
q=w/1;
imverytired.append(q,nothealthytired[6]);
w=w%1;
//..............................................................................
cout<<i<<"="<<nothing<<"="<<imverytired<<"="<<nothing<<"="<<imverytired<<end;
nothing="";
imverytired="";
}
system("pause");
return 0;
}
|