1043. 输出PATest

来源:互联网 发布:分班软件 编辑:程序博客网 时间:2024/06/05 00:20

1043. 输出PATest(20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue

给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按“PATestPATest....”这样的顺序输出,并忽略其它字符。当然,六种字符的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按PATest的顺序打印,直到所有字符都被输出。

输入格式:

输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。

输出格式:

在一行中按题目要求输出排序后的字符串。题目保证输出非空。

输入样例:
redlesPayBestPATTopTeePHPereatitAPPT
输出样例:
PATestPATestPTetPTePePee
123456789101112131415161718192021222324252627282930
#include <stdio.h>int main(){  int arr[58][1] = { 0 }, count = 0;  char ch;  while ((ch = getchar()) != '\n')  {    arr[ch - 65][0]++;    if (ch == 'P' || ch == 'A' || ch == 'T' || ch == 'e' || ch == 's' || ch == 't')      count++;  }  while (count--)  {    switch (1)    {    case 1:      if (arr[15][0]!= 0)  {printf("P"); arr[15][0]--;}          //这里的switch是我自己强加的,我就想试试switch的奇技淫巧,这里    case 2:                                                        不加break会一直把case遍历完,我觉得挺有意思的,一般写题直接      if (arr[0][0] != 0) { printf("A"); arr[0][0]--; }            if就行了    case 3:      if (arr[19][0] != 0) { printf("T"); arr[19][0]--; }    case 4:      if (arr[36][0] != 0) { printf("e"); arr[36][0]--; }    case 5:      if (arr[50][0] != 0) { printf("s"); arr[50][0]--; }    case 6:      if (arr[51][0] != 0) { printf("t"); arr[51][0]--; }    }  }}

0 0
原创粉丝点击