全部评论
这个题我在笔试的时候也遇到过
相关推荐
点赞 评论 收藏
分享
import java.io.BufferedReader; import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); String line1 = scanner.nextLine(); String line2 = scanner.nextLine(); char[] str1 = line1.toCharArray(); char cr = line2.toCharArray()[0]; int count = 0; for(int i=0; i<str1.length; i++){ char ca = str1[i]; if(String.valueOf(ca).equalsIgnoreCase(String.valueOf(cr))){ count++; } } System.out.println(count); } }
相关推荐