mirror of
https://github.com/xlucn/PAT.git
synced 2026-02-06 10:24:02 +08:00
20 lines
506 B
C
20 lines
506 B
C
#include <stdio.h>
|
|
|
|
int main()
|
|
{
|
|
char c, *str = "PATest"; /* use as index for count[] */
|
|
int i, flag = 1, count[128] = {0}; /* for each ASCII char */
|
|
|
|
/* Read and count numbers for every character */
|
|
while ((c = getchar()) != EOF && c != '\n')
|
|
count[(int)c]++;
|
|
|
|
/* Print any character in "PATest" if it is still left */
|
|
while (flag)
|
|
for (i = 0, flag = 0; i < 6; i++)
|
|
if (count[(int)str[i]]-- > 0) /* Check the number left */
|
|
putchar(str[i]), flag = 1;
|
|
|
|
return 0;
|
|
}
|