-
Notifications
You must be signed in to change notification settings - Fork 1
/
1043. 输出PATest(20)
61 lines (61 loc) · 1023 Bytes
/
1043. 输出PATest(20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<stdio.h>
#include<string.h>
int main(){
int kirby[6] = {0};
char n;
while ((n = getchar()) != '\n'){
if (n == 'P'){
kirby[0]++;
}
if (n == 'A'){
kirby[1]++;
}
if (n == 'T'){
kirby[2]++;
}
if (n == 'e'){
kirby[3]++;
}
if (n == 's'){
kirby[4]++;
}
if (n == 't'){
kirby[5]++;
}
}
int flag = 1;
while (flag){
flag = 0;
if(kirby[0]){
printf("P");
kirby[0]--;
flag = 1;
}
if(kirby[1]){
printf("A");
kirby[1]--;
flag = 1;
}
if(kirby[2]){
printf("T");
kirby[2]--;
flag = 1;
}
if(kirby[3]){
printf("e");
kirby[3]--;
flag = 1;
}
if(kirby[4]){
printf("s");
kirby[4]--;
flag = 1;
}
if(kirby[5]){
printf("t");
kirby[5]--;
flag = 1;
}
}
return 0;
}