Sorting Values my Integer and Decimal Values
8 次查看(过去 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
0 个评论
回答(1 个)
Chunru
2022-9-30
p = [8.1 8.2];
if floor(p(1)) == floor(p(2))
disp("A pair.")
end
f = [2.1 , 3.1 , 4.1, 5.1, 6.1];
if all(abs(diff(mod(f,1))) < 1e-5)
disp("A Flush")
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!