how can I print some numbers in ascending order?
Mostra commenti meno recenti
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
Luna
il 2 Lug 2019
Do you have a limit? How many numbers you want to get from user?
Star Strider
il 2 Lug 2019
Since this sounds like homework, what functions are you allowed to use?
Rahma Sabbah
il 2 Lug 2019
Risposte (2)
Kaustav Bhattacharya
il 2 Lug 2019
1 voto
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
il 2 Lug 2019
0 voti
Hi,
Please check out below bubble sort algorithm:
Categorie
Scopri di più su Software Development in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!