• Lenguaje

    Pascal

  • Descripción

    Dado un año tecleado por el usuario, escriba el siglo al que pertenece. Recuerda que el siglo comienza el primer año de cada centenario, es por eso por lo que el año 1800 sigue siendo el siglo XVIII y será siglo XIX a partir de 1801. Nota. No se escriben todos los años, existe una fórmula para obtener las centenas del año.

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
program Siglo;
uses crt;

var anno, ano, siglo : integer;
begin
    write ('Ingresa el valor de anno: ');
    readln (anno);
    write ('Ingresa el valor de ano: ');
    readln (ano);
    siglo := (anno-ano mod 100) div 100;
    if ano mod 100<>0 then
        begin
            siglo := siglo+1;
        end;
    if siglo=1 then
        begin
            writeln ('I');
        end;
    if siglo=2 then
        begin
            writeln ('II');
        end;
    if siglo=3 then
        begin
            writeln ('III');
        end;
    if siglo=4 then
        begin
            writeln ('IV');
        end;
    if siglo=5 then
        begin
            writeln ('V');
        end;
    if siglo=6 then
        begin
            writeln ('VI');
        end;
    if siglo=7 then
        begin
            writeln ('VII');
        end;
    if siglo=8 then
        begin
            writeln ('VIII');
        end;
    if siglo=9 then
        begin
            writeln ('IX');
        end;
    if siglo=10 then
        begin
            writeln ('X');
        end;
    if siglo=11 then
        begin
            writeln ('XI');
        end;
    if siglo=12 then
        begin
            writeln ('XII');
        end;
    if siglo=13 then
        begin
            writeln ('XIII');
        end;
    if siglo=14 then
        begin
            writeln ('XIV');
        end;
    if siglo=15 then
        begin
            writeln ('XV');
        end;
    if siglo=16 then
        begin
            writeln ('XVI');
        end;
    if siglo=17 then
        begin
            writeln ('XVII');
        end;
    if siglo=18 then
        begin
            writeln ('XVIII');
        end;
    if siglo=19 then
        begin
            writeln ('XIX');
        end;
    if siglo=20 then
        begin
            writeln ('XX');
        end;
    if siglo=21 then
        begin
            writeln ('XXI');
        end;
    writeln ('Valor de siglo: ', siglo);
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.