L1-023. Output GPLT, l1-023 output gplt

Source: Internet
Author: User

L1-023. Output GPLT, l1-023 output gplt

A string of no more than 10000 English letters. Please re-adjust the character order, output in the order of "GPLTGPLT...", and ignore other characters. Of course, the numbers of the four types of characters (case-insensitive) are not necessarily the same. If a certain character has been output, the remaining characters are still printed in the GPLT order, until all characters are output.

Input Format:

Enter a non-empty string consisting of letters and letters that cannot exceed 10000 characters in a row.

Output Format:

Output the sorted string in one row according to the question requirement. Ensure that the output of the question is not empty.

Input example:

pcTclnGloRgLrtLhgljkLhGFauPewSKgt

Output example:

GPLTGPLTGLTGLGLL

Time Limit: 150 ms memory limit: 65536 kB code length limit: 8000 B Judgment program Standard author Chen Yue Note: Subject requirements, case insensitive, therefore, you must add a str [I] = a [j] + 'a'-'A' to determine the condition, that is, the ASCII gap between upper-case letters and lower-case letters.
#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 10001int GetMax(int c[]){    int i;    int max = 0;    for(i = 0; i < 4; i++)    {        if(c[i] > max)            max = c[i];    }    return max;}int main(){    char str[N+1];    char a[5] = {'G', 'P', 'L', 'T'};    int b[4] = {0};    int i;    int j;    int max;    scanf("%s", str);    for(i = 0; i < strlen(str); i++)    {        for(j = 0; j < 4; j++)        {            if(str[i] == a[j] || str[i] == a[j] +'a' - 'A')            {                b[j]++;            }        }    }    max = GetMax(b);    while(max != 0)        for(i = 0; i < 4; i++)        {            if(b[i] != 0)            {                printf("%c", a[i]);                b[i]--;                max = GetMax(b);            }        }    return 0;}

 

Related Article

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.