Trabajo de Juego de Galletas Metodo Numericos

2
PRIMER TRABAJO DE PROGRAMACION METODOS NUMERICOS TRABAJO N°3 Realizar un programa que cumpa lo siguiente:  Se tiene n galletas.  Se pueda sacar 1,2y3 galletas.  Pierde el último en retirar las galletas.  Se debe jugar con el computador.  Por lo general el computador debe ganar. Programando: Códigos clear %Juego de la galletas%  N=input('Ingresar el numero de galletas' ) PLAYER=input('Cuantas galletas recogeras:max a recojer es 3 galletas' ) M=PLAYER; while(N>1) if (N>M) N=(N-M); Galletasquesobra=N if(N>8) COM=3 end if(N==8) COM=3 end if(N==7) COM=2 end if (N==6) COM=1 end Galletasquesobra=N-COM  N=Galletasquesobra; end PLAYER=input('Cuantas galletas recogeras:max a recojer es 3 galletas' ) M=PLAYER; if and((N>1),(N<=5))  N=(N-M); Galletasquesobra=N if(N==5) COM=3 end if(N==4) COM=3 end if(N==3) COM=2 end if (N==2) COM=1 end 

Transcript of Trabajo de Juego de Galletas Metodo Numericos

PRIMER TRABAJO DE PROGRAMACION METODOS NUMERICOS

PRIMER TRABAJO DE PROGRAMACION METODOS NUMERICOS

TRABAJO N3Realizar un programa que cumpa lo siguiente: Se tiene n galletas. Se pueda sacar 1,2y3 galletas. Pierde el ltimo en retirar las galletas. Se debe jugar con el computador. Por lo general el computador debe ganar.

Programando:Cdigos clear%Juego de la galletas%N=input('Ingresar el numero de galletas')PLAYER=input('Cuantas galletas recogeras:max a recojer es 3 galletas')M=PLAYER;while(N>1)if (N>M) N=(N-M); Galletasquesobra=N if(N>8) COM=3 end if(N==8) COM=3 end if(N==7) COM=2 end if (N==6) COM=1 endGalletasquesobra=N-COMN=Galletasquesobra;endPLAYER=input('Cuantas galletas recogeras:max a recojer es 3 galletas')M=PLAYER;if and((N>1),(N