make different numbers with the same digits
Afficher commentaires plus anciens
I have to ask the user for a positive integer ( input=('give a positive integer') and then ask him through a menu if he wants to make a bigger or smaller number with the same digits so Matlab will calculates the requested number.
2 commentaires
Ameer Hamza
le 19 Oct 2020
What if use input 999? Also, if you just want a bigger number, you can add 1.
Jens Petit-jean
le 19 Oct 2020
Réponses (2)
Vladimir Sovkov
le 19 Oct 2020
x=1342;
y=str2num(sort(num2str(x),'ascend')); % smaller
z=str2num(sort(num2str(x),'descend')); % bigger
1 commentaire
Jens Petit-jean
le 19 Oct 2020
KSSV
le 19 Oct 2020
str = '215' ;
num = str2num(perms(str)) ;
greater = num(num>str2num(str))
lesser = num(num<str2num(str))
1 commentaire
Jens Petit-jean
le 19 Oct 2020
Catégories
En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!