我無法找到一對大小爲5的字符串。因此,只能有兩對。對於我發現的每一對,我都應該將分數提高2分。 這是我到目前爲止,但它是不正確的。查找對中的五個
String temp = "4 5 4 3 3";
String tempLine = temp.replaceAll(" ", "");
String[] hand = temp.split(" ");
for(int i = 0; i < hand.length; i++)
{
if(hand[i].equals(tempLine.substring(0, 1)) && i !=0)
score += 1;
if(hand[i].equals(tempLine.substring(1, 2)) && i != 1)
score += 1;
if(hand[i].equals(tempLine.substring(2, 3)) && i!= 2)
score += 1;
if(hand[i].equals(tempLine.substring(3, 4)) && i!= 3)
score += 1;
if(hand[i].equals(tempLine.substring(4)) && i != 4)
score += 1;
}
編輯:我試圖找到具有相似值的手對,例如4將是這一手
你可以再提供一些代碼嗎?還有更多解釋你想要完成的事情! – Michael 2010-12-04 20:38:07