参考代码:
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 人评分
简单的a+b (C语言代码)浏览:583 |
用筛法求之N内的素数。 (C语言代码)浏览:685 |
陶陶摘苹果2 (C语言代码)浏览:651 |
C语言训练-自守数问题 (C语言代码)浏览:798 |
输入输出格式练习 (C语言代码)浏览:773 |
简单的事情 (C语言代码)浏览:679 |
【计算球体积】 (C语言代码)浏览:1619 |
1250题解浏览:604 |
剔除相关数 (C语言代码)浏览:1156 |
陶陶摘苹果2 (C++代码)浏览:578 |