Hdu 2025 Find the largest element (Java)

Source: Internet
Author: User

Problem:

This class is best used to manipulate character elements using a character array.

To get angry. The last element to be empty, there are two cases where the last element can be processed directly.


Find the largest elementTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 35186 Accepted Submission (s): 19474


Problem description for each string entered, look for the largest letter in it, and insert the string "(max)" After the letter.

Input data includes multiple test instances, each of which consists of a string of up to 100 characters and a string consisting only of uppercase and lowercase letters.

Output prints a single line of string for each test instance, and the result of the output is the result of inserting the string "(max)" and inserting "(max) after each of the maximum letters if there are multiple maximum letters."

Sample Input
Abcdefgfedcbaxxxxx

Sample Output
ABCDEFG (max) Fedcbax (max) x (max) x (max) x (max)

Code:

Import java.util.*;p ublic class main{public static void Main (String args[]) {Scanner cin=new Scanner (system.in); while ( Cin.hasnext ()) {String m=cin.next (); char[] S=m.tochararray (); Char maxx= ' a ' -1;for (int i=0;i<s.length;i++) {if (Maxx <s[i]) {maxx=s[i];}} for (int i=0;i<s.length;i++) {if (i==s.length-1) {if (S[i]==maxx) {System.out.println (s[i]+ "(max));} ElseSystem.out.println (S[i]);} Else{if (S[i]==maxx) {System.out.print (s[i]+ "(max)");} ElseSystem.out.print (S[i]);}}}}


Hdu 2025 Find the largest element (Java)

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.