Borrar filtros
Borrar filtros

Number guessing game with integers

4 visualizaciones (últimos 30 días)
torre
torre el 23 de Dic. de 2019
Editada: torre el 23 de Dic. de 2019
l

Respuestas (1)

David Hill
David Hill el 23 de Dic. de 2019
r = randi([1,10]);
numb = 0;
n = 0;
Numb=[];
while numb ~= r
numb = input('Guess the number between 1 and 10: ');
if ~ismember(numb,Numb)
n = n+1;
Numb=[Numb,numb];
end
if numb < r
fprintf('Your guess (%i) is below the actual number \n', numb)
elseif numb > r
fprintf('Your guess (%i) is above the actual number \n', numb)
else
fprintf('Congratulations, you guessed the right number %d!\n', r)
end
end

Categorías

Más información sobre Number games en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by