From four different numbers, how can I find out the minimum and maximum numbers that can created from the digits?

1 回表示 (過去 30 日間)
e.g., from 7465 :
The digits = 7, 4, 6, and 5, so:
Minimum = 4567, the maximum = 7654

採用された回答

Iman Ansari
Iman Ansari 2013 年 5 月 12 日
Hi.
A=7465;
A=num2str(A)';
Minimum=str2num(sort(A)')
maximum=str2num(sort(A,'descend')')
  3 件のコメント
Iman Ansari
Iman Ansari 2013 年 5 月 13 日
A=7465;
A=num2str(A)';
A_sort=sort(A);
New=str2num([A_sort([3 2 4 1])]')

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by