Sorting Values my Integer and Decimal Values

8 visualizaciones (últimos 30 días)
MattLab
MattLab el 30 de Sept. de 2022
Respondida: Chunru el 30 de Sept. de 2022
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

Respuestas (1)

Chunru
Chunru el 30 de Sept. de 2022
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

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by