题解 | #计算某字母出现次数#

计算某字母出现次数

http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String s = input.nextLine().toLowerCase();
char[] cs = s.toCharArray();
String s2 = input.next().toLowerCase();
char c = s2.toCharArray()[0];
int o = 0;
for(int i=0;i<cs.length;i++){
if(cs[i] == c)o++;
}
System.out.print(o);

}

}

全部评论

相关推荐

我就是0offer糕手:北大不乱杀
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务