题解 | #计算某字符出现次数#
计算某字符出现次数
http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String s1 = scanner.nextLine();
String s2 = scanner.nextLine();
char[] s1List = s1.toLowerCase().toCharArray();
char[] s2List = s2.toLowerCase().toCharArray();
int number = 0;
for (char c : s1List) {
if (c == s2List[0]) {
number++;
}
}
System.out.println(number);
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String s1 = scanner.nextLine();
String s2 = scanner.nextLine();
char[] s1List = s1.toLowerCase().toCharArray();
char[] s2List = s2.toLowerCase().toCharArray();
int number = 0;
for (char c : s1List) {
if (c == s2List[0]) {
number++;
}
}
System.out.println(number);
}
}