Azzera filtri
Azzera filtri

how can I print some numbers in ascending order?

4 visualizzazioni (ultimi 30 giorni)
a= input('please enter a number:');
b= input('enter second number:');
c= input('enter number:');
I do not know how to print some numbers that user enter in ascending order.
  3 Commenti
Star Strider
Star Strider il 2 Lug 2019
Since this sounds like homework, what functions are you allowed to use?
Rahma Sabbah
Rahma Sabbah il 2 Lug 2019
I have a limit to 3 numbers
I am allowed to use for, if and while functions

Accedi per commentare.

Risposte (2)

Kaustav Bhattacharya
Kaustav Bhattacharya il 2 Lug 2019
You have a, b, c. If you can use >,< then the following implemention can be used.
max = (a>b)*a + (a<b)*b
max = (max>c)*max + (max<c)*c
min = (a>b)*b + (a<b)*a
min = (min>c)*c + (min<c)*min
mid = (max~=a & min~=a)*a + (max~=b & min~=b)*b + (max~=c & min~=c)*c
disp([min,mid,max])

Luna
Luna il 2 Lug 2019

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by