Hdu2025 Max element search

Source: Internet
Author: User

Original question: Problem Description searches for the maximum letter of each input string, and inserts the string "(max)" after the letter )". Input data includes multiple test instances. Each instance consists of a string of no more than 100 characters in length. The string consists of only uppercase and lowercase letters. Output outputs a line of strings for each test instance. The Output result is the result of inserting the string "(max)". If there are multiple largest letters, insert "(max)" after each maximum letter )". Sample Input abcdefgedcbaxxxxx Sample Output abcdefg (max) fedcbax (max) x (max) original code: [cpp] # include <stdio. h> int main () {char t [128]; char max; int I; while (gets (t) {for (max = I = 0; t [I]; I ++) {if (t [I]> max) max = t [I] ;}for (I = 0; t [I]; I ++) {putchar (t [I]); if (t [I] = max) printf ("% s", "(max )");} putchar ('\ n');} return 0 ;}

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.