public class PKP {
public static void main(String[] args) {
String[] str1 = {"A", "5", "3", "K", "5", "6", "8", "8", "9", "10", "J", "Q", "K"};
Integer[] aa = getArray(str1);
//冒泡方式进行排序
for (int i = 0; i < aa.length; i++) {
for (int j = i; j < aa.length; j++) {
if (aa[i] > aa[j]) {
int temp = aa[i];
aa[i] = aa[j];
aa[j] = temp;
}
}
}
String[] as = new String[aa.length];
for (int i = 0; i < aa.length; i++) {
String st;
if (aa[i].equals(0)) {
st = "A";
} else if (aa[i].equals(11)) {
st = "J";
} else if (aa[i].equals(12)) {
st = "Q";
} else if (aa[i].equals(13)) {
st = "K";
} else {
st = aa[i] + "";
}
as[i] = st;
}
System.out.println();
}
//将扑克牌转换成数字数字进行对比
private static Integer[] getArray(String[] str1) {
Integer[] arr = new Integer[str1.length];
for (int i = 0; i < str1.length; i++) {
if (str1[i].equals("A")) {
str1[i] = str1[i].replace("A", "0");
}
if (str1[i].equals("J")) {
str1[i] = str1[i].replace("J", "11");
}
if (str1[i].equals("Q")) {
str1[i] = str1[i].replace("Q", "12");
}
if (str1[i].equals("K")) {
str1[i] = str1[i].replace("K", "13");
}
arr[i] = Integer.parseInt(str1[i]);
}
return arr;
}
}
02-09
3535
06-30
753