Tabla de multiplicar en numeros romanos
Publicado por juan reyes (1 intervención) el 20/10/2007 22:35:23
Tengo que escribir un programa que dado un entero entre 1 y 15 por el operador, el programa saque la tabla de ese numero en romanos, es decir:
TABLA DE MULTIPLICAR DEL 2
II x I = II
II x II = IV
y así.
He escrito este algoritmo, sin embargo, el compilador me dice que le falta un begin a tablamultiplicar pero si que tiene uno, por que no lo ve?
TABLA DE MULTIPLICAR DEL 2
II x I = II
II x II = IV
y así.
He escrito este algoritmo, sin embargo, el compilador me dice que le falta un begin a tablamultiplicar pero si que tiene uno, por que no lo ve?
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
------------------------------------------------------------------------------------------------
WITH Ada.Text_IO, Ada.Integer_Text_IO;
------------------------------------------------------------------------------------------------
PROCEDURE TablaMultiplicar IS
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
USE Ada.Text_IO, Ada.Integer_Text_IO;
---------------------------------------------------------------------------------------------
PROCEDURE TransformarRomanos (Numero : IN Integer) IS
---------------------------------------------------------------------------------------------
-- Transforma el numero entero contenido en "numero" en su equivalente con cifras romanas.
--
---------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
PROCEDURE TransformarCaracter (Numero : IN Integer; Uno, Cinco, Diez : IN Character) IS
------------------------------------------------------------------------------------------
-- Dado un numero entre 1 y 9, contenido en la variable "numero", nos devuelve su caracter romano.
------------------------------------------------------------------------------------------
i : integer;
begin
i := 0;
if numero >= 1 and numero <= 3 then
while i /= numero loop
i := i + 1;
put(uno);
end loop;
elsif numero = 4 then put(uno);put(cinco);
elsif numero >= 5 and numero <= 8 then
put(cinco);
while i + 5 < numero loop
i := i + 1;
put(uno);
end loop;
elsif numero = 9 then
put(uno);put(diez);
end if;
end TransformarCaracter;
-------------------------------------------------------------------------------------------
begin
if numero > 3999 then put(" OPERACION FUERA DE RANGO (MAXIMO REPRESENTABLE: 3999)");
else
transformarCaracter(numero/1000,'M',' ',' ');
transformarCaracter(numero/100 mod 10,'C','D','M');
transformarCaracter(numero/10 mod 10,'X','L','C');
transformarCaracter(numero mod 10,'I','V','X');
end if;
END TransformarRomanos;
-----------------------------------------------------------------------------------
Numero: Integer; Entero := TransformarRomanos(Numero); I: Integer;
operando := transformarRomanos(i); resultado: integer; res := transformarRomanos(resultado);
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
BEGIN
Put("De que numero desea su tabla de multiplicar (entre 1 y 15): "); Get(Numero);
Skip_Line; New_Line;
Put("TABLA DE MULTIPLICAR DEL "); Put(entero,1); New_Line(2);
FOR I IN 1..10 LOOP
Put(entero,0); Put(" x "); Put(operando,0);
Put(" = "); Put(res,0); New_Line;
END LOOP;
END TablaMultiplicar;
----------------------------------------------------------------------------------------
Valora esta pregunta
0