ROMANO_DECIMAL_01.c



// conversiOn de romano a decimal

#include <stdio.h>

#define I 1
#define V 5
#define X 10
#define L 50

int main(int N, char **Args)
{
	int i, total, Ant,Act;
	i = total = Ant = Act = 0;
	
	
	char romano[80];

	printf("NUmero romano: ");
	scanf("%s", romano);

inicio:	if ( romano[i] == '\0' ) goto fin;

	if ( romano[i] == 'I' ) { Ant = I; total += I; }
	if ( romano[i] == 'V' )
	{
		if ( Ant < V ) { total += V; }
		else	{ total = total+3; Ant = V; }
		Ant=V;
	}
	if ( romano[i] == 'X' )
	{
		if ( Ant < X ) { total = total+X-Ant; Ant = X; }
		else	total += X;
	}
	i++; goto inicio;


fin:	printf("Total= %d\n", total);
	printf("fin\n");
}