HDU 1219 AC Me

Source: Internet
Author: User

Test instructions: Water problem ... is to ask for the number of letters A-Z appears. Note There is a blank line between each test event.


Import Java.util.scanner;public class Main {public static void main (string[] args) {Scanner sc = new Scanner (system.in); T[] Mat = new Int[26];int temp = 0;while (Sc.hasnext ()) {String test = Sc.nextline ();//initialized to 0 for (int i = 0; i < Mat.lengt H i++) {Mat[i] = 0;} for (int i = 0; i < test.length (); i++) {Char ch = test.charat (i); if (ch<= ' z ' &&ch>= ' a ') {temp = (int) (ch-' A '); mat[temp]++;}} for (int i = 0; i < mat.length; i++) {System.out.println ((char) (' a ' +i) + ":" +mat[i]);} System.out.println ();//This Note}}}




AC Me Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 13911 Accepted Submission (s): 6110


Problem Descriptionignatius is doing he homework now. The teacher gives him some articles and asks him to tell what many times each letter appears.
Ignatius Matthews is doing his homework now. His teacher gave him several articles and asked him to find out the number of times each letter appeared in each article.
It ' s really easy, isn ' t it? So come on and AC ME.
It's really easy, right? To! Let's solve him.
Inputeach article consists of just one line, and all the letters is in lowercase. You just has to count the number of every letter, there is only one line for each article, and the letters you enter are lowercase. Your task is to calculate the number of occurrences of each letter. So does not pay attention to other characters. The length of article is at most 100000. Process to the end of file.
So there's no need to think about other letters. The length of the article is less than or equal to 100,000. Enter directly to the end of the file.
Note:the problem have multi-cases, and you could use "while (gets (BUF)) {...}" to process to the end of file.
Note: There are multiple problems, you can use the "while (BUF) {...}" statement to deal with the problem and know the end of the file.
Outputfor Each article, you have the to tell how many times each letter appears. The output format is like "X:n".
For each article, you must calculate the number of occurrences of each letter. The format of the input is shown in the following example.
Output a blank line after each test case. More details in sample output.
Each test event is isolated with a blank line.
Sample Input
Hello, this is my first ACM contest!work hard for HDU ACM.

HDU 1219 AC Me

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.