how can I print some numbers in ascending order?

7 ビュー (過去 30 日間)
Rahma Sabbah
Rahma Sabbah 2019 年 7 月 2 日
回答済み: Kaustav Bhattacharya 2019 年 7 月 2 日
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 件のコメント
Star Strider
Star Strider 2019 年 7 月 2 日
Since this sounds like homework, what functions are you allowed to use?
Rahma Sabbah
Rahma Sabbah 2019 年 7 月 2 日
I have a limit to 3 numbers
I am allowed to use for, if and while functions

サインインしてコメントする。

回答 (2 件)

Kaustav Bhattacharya
Kaustav Bhattacharya 2019 年 7 月 2 日
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 2019 年 7 月 2 日

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by