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
|
#include "stdafx.h"
#include "romanType.h"
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
romanType::romanType()
{
}
void romanType:: GetArabicNumber(int num)
{
RomanStr.clear();
ArabicInt = num;
}
void romanType:: GetRomanNumeral(std::string str)
{
RomanStr.clear();
RomanStr = str;
RomanStr += " ";
}
void romanType:: ConvertArabicToRoman()
{
int h, th, t, o, num;
char *ones[] = {"","I","II","III","IV","V","VI","VII","VIII","IX"};
char *tens[] = {"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
char *hundreds[] = {"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
char *thousands[] = {"","M","MM","MMM","MMMM","MMMMM"};
if (num <= 5000)
{
th = num / 1000;
num = num % 1000; // get rid of the 1000s
h = num % 100;
num = num % 100; // get rid of the 100s
t = num / 10;
o = num % 10;
RomanStr = RomanStr + thousands[th] + hundreds[h] + tens[t] + ones[o];
}
}
string romanType:: PrintRomanNumeral(){
return(RomanStr);
}
int romanType:: PrintArabicNumber()
{
return(ArabicInt);
}
romanType:: ~romanType()
{
}
|