• Lenguaje

    Pascal

  • Descripción

    Los colores primarios son el rojo, amarillo y azul, los secundarios naranja, verde y violeta. Determinar a partir del ingreso de dos colores primarios y el color secundario que se pueda crear, por ejemplo azul y amarillo formar verde, rojo y amarrillo forman naranja y rojo y azul forman violeta. Si no se puede formar ningún color secundario mostrar un mensaje de error, cosa contrario mostrar el color.

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
program ColorSecundario;
uses crt;

var color_1, color_2 : integer;
begin
    writeln ('Selecciona el valor de color 1.');
    writeln ('    1.- Rojo');
    writeln ('    2.- Amarillo');
    writeln ('    3.- Azul');
    write ('    : ');
    repeat
        readln (color_1);
        if (color_1<1) or (color_1>3) then
            write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
    until (color_1>=1) and (color_1<=3);
    writeln ('Selecciona el valor de color 2.');
    writeln ('    1.- Rojo');
    writeln ('    2.- Amarillo');
    writeln ('    3.- Azul');
    write ('    : ');
    repeat
        readln (color_2);
        if (color_2<1) or (color_2>3) then
            write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
    until (color_2>=1) and (color_2<=3);
    if ((color_1=3) and (color_2=2)) or ((color_1=2) and (color_2=3)) then
        begin
            writeln ('Verde');
        end;
    if ((color_1=1) and (color_2=2)) or ((color_1=2) and (color_2=1)) then
        begin
            writeln ('Naranja');
        end;
    if ((color_1=1) and (color_2=3)) or ((color_1=3) and (color_2=1)) then
        begin
            writeln ('Violeta');
        end;
    if color_1=color_2 then
        begin
            writeln ('Error');
        end;
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.