牛客华为机试题库【题号 HJ开头】(重点看)
牛客在线编程算法篇【题号NC开头】
剑指offer【题号 JZ开头】
力扣
1)原题链接
2)已有题解
3)代码
package string;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Locale;
import static java.lang.System.in;
public class HJ2CountTheNumberOfOccurrencesOfACharacter {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
char[] chars = bf.readLine().toLowerCase(Locale.ROOT).toCharArray();
char[] chars2 = bf.readLine().toLowerCase(Locale.ROOT).toCharArray();
bf.close();
int count = 0;
for (int i = 0; i < chars.length; i++) {
if (chars[i] == chars2[0]) {
count++;
}
}
System.out.println(count);
}
}