解题思路:参考别人的思路
注意事项:定义字符串来排序,contains()来匹配,注意两牌相等也是NO
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String []str={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
int N=scanner.nextInt();
int a=0;
int c=0;
for(int i=1;i<=N;i++){
String king=scanner.next();
String str1=scanner.next();
String str2=scanner.next();
for(int j=0;j<=12;j++){
if(str1.contains(str[j]))
{ a=j;
break;}
}
for(int k=0;k<=12;k++){
if(str2.contains(str[k]))
{ c=k;
break;}
}
if(str1.contains(king)&&!str2.contains(king))
System.out.println("YES");
else if(str1.contains(king)&&str2.contains(king)&&a>c)
System.out.println("YES");
else if(!str1.contains(king)&&!str2.contains(king)&&a>c)
System.out.println("YES");
else
System.out.println("NO");
}
}
}
0.0分
1 人评分
最小公倍数 (C语言代码)浏览:1025 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:466 |
复数求和 (C语言代码)浏览:916 |
陶陶摘苹果2 (C语言代码)浏览:595 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:527 |
【计算直线的交点数】 (C语言代码)浏览:916 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:546 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:809 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:525 |
C语言训练-求车速 (C语言代码)浏览:799 |