-
Lenguaje
SciLab
-
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
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
color_1 = 0;
while color_1==0
color_1 = x_choose(["Rojo", "Amarillo", "Azul"], "Selecciona el valor de color 1.");
if color_1==0 then
printf ("Valor incorrecto. Ingrésalo nuevamente.: ");
end,
end;
color_2 = 0;
while color_2==0
color_2 = x_choose(["Rojo", "Amarillo", "Azul"], "Selecciona el valor de color 2.");
if color_2==0 then
printf ("Valor incorrecto. Ingrésalo nuevamente.: ");
end,
end;
if (color_1==3 & color_2==2) | (color_1==2 & color_2==3) then
printf ("Verde\n");
end,
if (color_1==1 & color_2==2) | (color_1==2 & color_2==1) then
printf ("Naranja\n");
end,
if (color_1==1 & color_2==3) | (color_1==3 & color_2==1) then
printf ("Violeta\n");
end,
if color_1==color_2 then
printf ("Error\n");
end,
end
while color_1==0
color_1 = x_choose(["Rojo", "Amarillo", "Azul"], "Selecciona el valor de color 1.");
if color_1==0 then
printf ("Valor incorrecto. Ingrésalo nuevamente.: ");
end,
end;
color_2 = 0;
while color_2==0
color_2 = x_choose(["Rojo", "Amarillo", "Azul"], "Selecciona el valor de color 2.");
if color_2==0 then
printf ("Valor incorrecto. Ingrésalo nuevamente.: ");
end,
end;
if (color_1==3 & color_2==2) | (color_1==2 & color_2==3) then
printf ("Verde\n");
end,
if (color_1==1 & color_2==2) | (color_1==2 & color_2==1) then
printf ("Naranja\n");
end,
if (color_1==1 & color_2==3) | (color_1==3 & color_2==1) then
printf ("Violeta\n");
end,
if color_1==color_2 then
printf ("Error\n");
end,
end