【PAT B 1043】输出PATest

#include 
#include 
using namespace std;
const int maxn = 10010;
int main(){
    char list[maxn],outlist[6] = {'P','A','T','e','s','t'},c1;
    int len,HashTable[6] = {0},number = 0;
    scanf("%s",list);
    len = strlen(list);

    for(int i = 0;i < len;i++){
        for(int j = 0;j < 6;j++){
            if(list[i] == outlist[j]) {
                HashTable[j]++;
                number++;
            }
        }
    }

    while(number > 0){
        for(int i =0;i < 6;i++) {
            if ((HashTable[i]) > 0) {
                printf("%c",outlist[i]);
                HashTable[i]--;
                number--;
            }
        }
    }
    return 0;
}

你可能感兴趣的:(【PAT B 1043】输出PATest)