参考代码:
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double x = scanner.nextDouble(); scanner.nextLine(); String s1 = scanner.nextLine(); String s2 = scanner.nextLine(); System.out.print((compareStrings(s1, s2) / (double)s1.length() >= x) ? "yes" : "no"); } public static int compareStrings(String str1, String str2) { int count = 0; Pattern pattern = Pattern.compile("[a-zA-Z]"); Matcher matcher1 = pattern.matcher(str1); Matcher matcher2 = pattern.matcher(str2); while (matcher1.find() && matcher2.find()) if (matcher1.group().equals(matcher2.group())) count++; return count; } }
0.0分
4 人评分
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:659 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:590 |
字符串输入输出函数 (Java代码)浏览:1495 |
【偶数求和】 (C语言代码)浏览:674 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:758 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:646 |
DNA (C语言代码)浏览:563 |
1113题解浏览:822 |
A+B for Input-Output Practice (C语言代码)浏览:504 |
陈教主的三角形 (C语言代码)浏览:1196 |