L
level9
How can I convert roman numerals to intergers in c++ VS 6?
level9 said:How can I convert roman numerals to intergers in c++ VS 6?
level9 said:How can I convert roman numerals to intergers in c++ VS 6?
How can I convert roman numerals to intergers in c++ VS 6?
(Is 'iiii' a valid representation of 4, can 99 be written as 'ic' or
must it be written as 'lxxxix', ...?)
</level9>How can I convert roman numerals to intergers in c++ VS 6?
Agent Mulder said:</level9>
Here you have a converter from integers to roman numerals (level4)
#include<iostream.h>
#include said:#include<string>
static int i=1;
static int x=10;
static int c=100;
static int m=1000;
static string I[]={"","I","II","III","IV","V","VI","VII","VIII","IX"};
static string X[]={"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
static string C[]={"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
static string M[]={"","M","MM","MMM"};
string roman(int a){return M[(a/m)%10]+C[(a/c)%10]+X[(a/x)%10]+I[(a/i)%10];}
int main(int argc,char**argv)
{
argc<2
?
cout<<"\nAugust Number Converter Version 1.0\nUsage: August int"
:
atoi(argv[1])<0
?
cout<<"\nNo negative numbers allowed"
:
atoi(argv[1])>3999
?
cout<<"\nNo numbers greater than 3999 allowed"
:
cout<<roman(atoi(argv[1]));
return 0;
}
level9 said:How can I convert roman numerals to intergers in c++ VS 6?
<snip>VS, stands for "verses", as in "kansas vs. the school board",
right?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.