参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { // 统计一个给定字符串中指定的字符出现的次数。 Scanner sc = new Scanner(System.in); while(sc.hasNext()) { String str1 = sc.nextLine(); if(str1.equals("#")) { return; } String str2 = sc.nextLine(); for (int i = 0; i < str1.length(); i++) { int count = 0; for (int j = 0; j < str2.length(); j++) { if(str1.charAt(i) == str2.charAt(j)) { count++; } if(j == str2.length()-1) { System.out.println(str1.charAt(i) + " " + count); } } } } } }
0.0分
4 人评分
The 3n + 1 problem (C++代码)(所有测试数据都小于等于1000,,说好的1000000之内呢)浏览:1098 |
点我有惊喜!你懂得!浏览:1402 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:1053 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:725 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:411 |
淘淘的名单 (C语言代码)浏览:1104 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:840 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:595 |
水仙花 (C语言代码)浏览:1051 |
1011题解浏览:764 |