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

计算某字符出现次数

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

import java.io.BufferedReader; import java.io.InputStreamReader;

public class Main { public static void main(String[] args) throws Exception{ String word="",word1 = ""; BufferedReader buf= new BufferedReader(new InputStreamReader(System.in)); word = buf.readLine().toLowerCase(); word1 = buf.readLine().toLowerCase(); int index = 0; for(int i= 0;i<word.length();i++){ if (word.charAt(i)==word1.charAt(0)) index++; } System.out.println(index); } }

全部评论

相关推荐

码农顶针:估计让你免费辅导老板孩子的学习
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务