Posted By: Jovo () on 'CZprogram'
Title:     Kde hledat
Date:      Mon Dec 16 17:59:21 2002

Ahoj.

  Hledal jsem algoritmus pro prevod Rimskych cisel na Arabska a pres Google 
jsem narazil na paradni stranku, kde je snad vsechno:

http://www.planet-source-code.com/

Jovo.
PS: Brutus algoritmus pro R->A konverzi: 

//**************************************
// Name: Convert_Roman_Nos.
// Description:THIS IS THE "FASTEST" ALGORITHM FOR CONVERSION OF ROMAN 
NUMERALS INTO NUMBERS.IT WILL CONVERT ALL ROMAN NUMERALS INTO NUMBERS IN 
RECORD TIME.IF ANY ONE KNOWS ANY FASTER METHOD PLEASE LET ME KNOW.
// By: Anirudh Wadhwa
//
//
// Inputs:None
//
// Returns:None
//
//Assumes:THIS PROGRAM WILL CONVERT ROMAN NUMERALS INTO NUMBERS REGARDLESS OF 
THEIR CASE.XXIV = xxiv = 24
//
//Side Effects:None
//This code is copyrighted and has limited warranties.
//Please see 
http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.885/lngWId.3/qx/vb/scripts/S
howCode.htm
//for details.
//**************************************

#include <iostream.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
//For Any Queries,MailMe themask99@yahoo.com 
void main()


    {
    char a[15];
    cout<<"Enter The Roman Number :"; 
    cin>>a;
    for(int x=0,p=0,flag=0,rom=0,int i=strlen(a)-1;i>=0;i--)


        {
        if (a[i]=='i' || a[i]=='I') x=1; 
        if (a[i]=='v' || a[i]=='V') x=5; 
        if (a[i]=='x' || a[i]=='X') x=10; 
        if (a[i]=='l' || a[i]=='L') x=50; 
        if (a[i]=='c' || a[i]=='C') x=100; 
        if (a[i]=='d' || a[i]=='D') x=500;
        if (a[i]=='m' || a[i]=='M') x=1000; 
        
        if (x<p) flag = -1; 
        else flag = 1;
        
        rom= rom + (x*flag);
        p=x;//storing the previous value in x
        }
        cout<<"Numerical value is : "<<rom;
        getch();
    }


 

Search the boards