标签:panel stat sample bsp ted size code pac turn
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1860
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 12731 Accepted Submission(s):
7918
import java.util.Scanner; public class Main { public static int count(char c,String string) { int num = 0; for(int i = 0;i < string.length();i++) { if(c == string.charAt(i)) { num++; } } return num; } public static void main(String[] args) { @SuppressWarnings("resource") Scanner inScanner = new Scanner(System.in); while(inScanner.hasNext()) { String string = inScanner.nextLine(); if(string.equals("#")) { break; } else { String string2 = inScanner.nextLine(); for(int i = 0 ;i<string.length();i++) { System.out.println(string.charAt(i) + " " + count(string.charAt(i), string2)); } } } } }
C++的count():
#include<iostream> #include <string> #include <algorithm> using namespace std; int main() { string a,b; while(getline(cin,a)) { if(a=="#") break; getline(cin,b); int len=a.length(); for(int i=0;i<len;i++) { int sum=count(b.begin(),b.end(),a[i]); printf("%c %d\n",a[i],sum); } } return 0; }
标签:panel stat sample bsp ted size code pac turn
原文地址:https://www.cnblogs.com/Weixu-Liu/p/9656462.html