Sorting Values my Integer and Decimal Values

8 ビュー (過去 30 日間)
MattLab
MattLab 2022 年 9 月 30 日
回答済み: Chunru 2022 年 9 月 30 日
Hello, I am attempting to create a poker hand Analyser. Right now I have all cards (2-A) correlated to an integer value (2-14). Then depending on their Suite (Heart, Diamond,Spade,Club) I add a decimal value ( .1, .2, .3, .4). Is there a way to have my code differentiate between the integers and decimal values?
For ex.) A pair would be 8.1 and 8.2.
and a flash would be 2.1 , 3.1 , 4.1, 5.1, 6.1
I want to say something like:
if integer= integer then hand is a pair
if deciemal = deciemal then we have a flush
Thank you

回答 (1 件)

Chunru
Chunru 2022 年 9 月 30 日
p = [8.1 8.2];
if floor(p(1)) == floor(p(2))
disp("A pair.")
end
A pair.
f = [2.1 , 3.1 , 4.1, 5.1, 6.1];
if all(abs(diff(mod(f,1))) < 1e-5)
disp("A Flush")
end
A Flush

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by