How to do a number selector

2 vues (au cours des 30 derniers jours)
danny walker
danny walker le 27 Avr 2021
Commenté : danny walker le 4 Mai 2021
I am trying to create a code similar to the lottery, where you have one option to select a lucky dip and then another option to select your own 6 numbers. Could nayone help me with how to do this please?
Thanks if you can help.

Réponse acceptée

David Hill
David Hill le 27 Avr 2021
I assume you mean something like this.
maxNum=50;
a=input('lucky dip==1 or choose your own numbers==2');
if a==1
numbers=randi(50,1,6);
else
numbers=input(sprintf('Input your six numbers less than or equal to %d, for example [1 2 3 4 5 6]',maxNum));
end
  1 commentaire
danny walker
danny walker le 4 Mai 2021
Perfect, thanks.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by