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)