HDOJ1219 AC Me
来源:互联网 发布:塔士多礼服 知乎 编辑:程序博客网 时间:2024/06/18 00:57
AC Me
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19712 Accepted Submission(s): 8288
Problem Description
Ignatius is doing his homework now. The teacher gives him some articles and asks him to tell how many times each letter appears.
It's really easy, isn't it? So come on and AC ME.
It's really easy, isn't it? So come on and AC ME.
Input
Each article consists of just one line, and all the letters are in lowercase. You just have to count the number of each letter, so do not pay attention to other characters. The length of article is at most 100000. Process to the end of file.
Note: the problem has multi-cases, and you may use "while(gets(buf)){...}" to process to the end of file.
Note: the problem has multi-cases, and you may use "while(gets(buf)){...}" to process to the end of file.
Output
For each article, you have to tell how many times each letter appears. The output format is like "X:N".
Output a blank line after each test case. More details in sample output.
Output a blank line after each test case. More details in sample output.
Sample Input
hello, this is my first acm contest!work hard for hdu acm.
Sample Output
a:1b:0c:2d:0e:2f:1g:0h:2i:3j:0k:0l:2m:2n:1o:2p:0q:0r:1s:4t:4u:0v:0w:0x:0y:1z:0a:2b:0c:1d:2e:0f:1g:0h:2i:0j:0k:1l:0m:1n:0o:2p:0q:0r:3s:0t:0u:1v:0w:1x:0y:0z:0
ASCII 码的使用,注意题目的要求,每个案例都跟一个空行
import java.util.Scanner;public class Main{private static Scanner scanner;public static void main(String[] args) {scanner = new Scanner(System.in);while(scanner.hasNext()){String string = scanner.nextLine();int arr[] = new int[26];for (int i = 0; i < string.length(); i++) {char ch = string.charAt(i);if(ch>='a' &&ch<='z'){int j = ch-97;arr[j]++;}}for (int i = 0; i < arr.length; i++) {char c = (char) (97+i);System.out.println(c+":"+arr[i]);}System.out.println();//在每个测试用例之后输出一个空行}}}
阅读全文
0 0
- 【水题】hdoj1219 AC me
- HDOJ1219 AC Me
- AC Me
- AC me
- AC Me
- AC Me
- AC Me
- AC Me
- AC Me
- hdu 1219 AC Me
- HDU AC me
- hdu 1219 AC Me
- hdu 1219 AC Me
- HDU 1219 AC Me
- hdu 1219 AC Me
- AC Me解题报告
- HDU 1219 AC Me
- HDOJ 1219 AC ME
- spirng3.1换成4.0后报错Exception sending context initialized event to listener instance of class
- VBA入门
- java实现c/c++ swap函数(java反射)
- 一个Python小白5个小时爬虫经历
- 趣图:这种事,程序员很常见呀
- HDOJ1219 AC Me
- Google AI 创造的 AI 超过人类创造的 AI
- 14张思维导图带你征服黑客也钟意的Python编程(附赠高清PDF)
- IPsec VPN基本原理
- ASP.NET FileUpload上传文件如果存在此文件提示是否覆盖
- js中遍历数据的多种情况
- python找出列表重复值
- aaa
- C++模板:函数模板和模板函数