PROGRAM Calculadora (input,output);
VAR
opcion:char;
a,b,limpiar:integer;
PROCEDURE Limpiar_pantalla(limpiar:integer);
BEGIN
FOR limpiar:=1 TO 50 DO
writeln(' ');END;
PROCEDURE Leer_numeros (VAR i,j:integer);
BEGIN
writeln(' '); write('Escriba el primer número: '); readln(i);
writeln(' '); write('Escriba el segundo número: '); readln(j);
writeln(' ');END; {leer}
PROCEDURE Sumar (x,y:integer);
BEGIN
writeln('La suma es: ',x+y);END;
PROCEDURE Restar (x,y:integer);
BEGIN
writeln('La resta es: ',x-y);END;
PROCEDURE Multiplicar (x,y:integer);
BEGIN
writeln('La multiplicación es: ',x*y);END;
PROCEDURE Dividir (x,y:integer);
BEGIN
writeln('La divisón es: ',(x/y):0:4);END;
PROCEDURE Menu;
BEGIN
writeln(' '); writeln('Elija una opción'); writeln(' '); writeln('1 - Sumar'); writeln('2 - Restar'); writeln('3 - Multiplicar'); writeln('4 - Dividir'); writeln('5 - Salir'); writeln(' ');END;{Menu}BEGIN {pp}REPEAT
Menu;
readln(opcion);
IF (opcion>= '1') and (opcion<='4') THEN
BEGIN
leer_numeros (a,b);
CASE opcion OF
'1': Sumar(a,b);
'2': Restar(a,b);
'3': Multiplicar(a,b);
'4': IF (b<>0) THEN Dividir(a,b)
ELSE writeln('No se puede dividir por 0'); END;{Case} END {IF} ELSE IF (opcion>'5') or (opcion<'1') THEN BEGIN
writeln(' '); writeln('Opción incorrecta'); END;
UNTIL opcion='5';
writeln(' '); writeln('Espero habrle ayudado, muchas gracias'); writeln(' '); writeln('Adios'); readln;
Limpiar_pantalla(limpiar);
END.
AQUI TE MANDO UN JUEGUECITO PARA QUE TE DIVIERTAS QUE HE HECHO YO EN PASCAL AUNQUE ES UN POCO CUTRE PERO VALE, JEJEJ
PROGRAM Juego_dardos (input,output);
CONST
N=100;
G=9.8;
VAR
t,y,x,d:real;
Vo,turno,tirada,puntuacion,total1,total2,jugador,angulo,distancia:integer;
BEGIN
writeln(' '); writeln('Bienvenido al juego: PROYECTILES'); writeln(' '); writeln('Esperamos que sea de su agrado y le deseamos un buen juego'); writeln(' '); writeln('Si desea salir en medio del juego pulse una letra'); writeln(' '); Randomize;
total1:=0;
total2:=0;
FOR turno:=1 TO 3 DO BEGIN
distancia:= random (100+1);
FOR jugador:=1 TO 2 DO BEGIN
FOR tirada:=1 TO 3 DO BEGIN
writeln(' '); writeln('Jugador ',jugador,', Turno ',turno,', Tirada ',tirada); writeln('Distancia a la diana ',distancia,' metros'); write('Escriba la velocidad del lanzamiento (m/s): '); readln(Vo);
write('Escriba el ngulo del lanzamiento (grados): '); readln(angulo);
t:=0;
REPEAT
t:=t+0.01;
y:=(Vo*(sin((angulo*pi/180))*t)-((G*(sqr(t)))/2));
UNTIL (y<=0.00);
x:=Vo*cos(angulo*pi/180)*(t-0.01);
d:=abs(distancia-x);
IF d<0.5 THEN puntuacion:=50;
IF (d>0.5) and (d<1) THEN puntuacion:=25;
IF (d>1) and (d<2) THEN puntuacion:=10;
IF (d>2) and (d<3) THEN puntuacion:=8;
IF (d>3) and (d<4) THEN puntuacion:=6;
IF (d>4) and (d<5) THEN puntuacion:=4;
IF (d>5) and (d<7) THEN puntuacion:=2;
IF (d>7) and (d<10) THEN puntuacion:=1;
CASE jugador OF
1:total1:=total1+puntuacion;
2:total2:=total2+puntuacion;
end;
writeln('Longitud del tiro : ',x:0:2,' metros'); writeln('Distancia a la diana : ',d:0:2,' metros'); if (puntuacion=1) then writeln('Puntuaci¢n del tiro: ', puntuacion, ' punto') else writeln('Puntuaci¢n del tiro: ', puntuacion, ' puntos'); case jugador of
1:begin
if (total1=1) then writeln('Total del jugador 1: ', total1, ' punto') else writeln('Total del jugador 1: ', total1, ' puntos'); end;
2:begin
if (total2=1) then writeln('Total del jugador 2: ', total2, ' punto') else writeln('Total del jugador 2: ', total2, ' puntos'); end;
END;
end;
end;
end;
IF total1>total2 THEN BEGIN
writeln('El ganador es el jugador 1, enhorabuena'); writeln('Su puntuaci¢n es :',total1,' , y la del jugador 2 es: ',total2); if total2<total1 THEN BEGIN
writeln('El ganador es el jugador 2, enhorabuena'); writeln('Su puntuaci¢n es :',total2,' , y la del jugador 1 es: ',total1); END
ELSE
writeln('Han empatado');
end;
end.