天天看點

L1-023. 輸出GPLT

L1-023. 輸出GPLT

//AC

#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
int main(){
    string s;
    int G,P,L,T;
    cin>>s;
    G=P=L=T=0;
    for (int i=0;i<=s.size() ; i++) {
        if(s[i]=='G'||s[i]=='g'){
            G++;
        }
        if(s[i]=='P'||s[i]=='p'){
            P++;
        }
        if(s[i]=='L'||s[i]=='l'){
            L++;
        }
        if(s[i]=='T'||s[i]=='t'){
            T++;
        }
    }
    while(G>0||P>0||L>0||T>0){
        if(G>0){cout<<"G";G--;}
        if(P>0){cout<<"P";P--;}
        if(L>0){cout<<"L";L--;}
        if(T>0){cout<<"T";T--;}
    }
    cout<<endl;
    return 0;
}


           
PAT