zoukankan      html  css  js  c++  java
  • 1043. 输出PATest(20)

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

    输入格式:

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

    输出格式:

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

    输入样例:

    redlesPayBestPATTopTeePHPereatitAPPT
    

    输出样例:

    PATestPATestPTetPTePePee
     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include<string.h>
     4 
     5 char str[10001];
     6 int main()
     7 {
     8     int numP=0,numT=0,numA=0,nume=0,nums=0,numt=0; //存放P A T e s t的个数
     9     int i;
    10     gets(str);
    11     for( i=0; str[i]!=''; i++)
    12     {
    13         switch( str[i])
    14         {
    15         case 'P':
    16             numP++;
    17             break;
    18         case 'A':
    19             numA++;
    20             break;
    21         case 'T':
    22             numT++;
    23             break;
    24         case 'e':
    25             nume++;
    26             break;
    27         case 's':
    28             nums++;
    29             break;
    30         case 't':
    31             numt++;
    32             break;
    33         default:
    34             break;
    35         }
    36     }
    37     while( numP||numA||numT||nume||nums||numt)
    38     {
    39         if(numP)
    40         {
    41             printf("P");
    42             numP--;
    43         }
    44         if(numA)
    45         {
    46             printf("A");
    47             numA--;
    48         }
    49         if(numT)
    50         {
    51             printf("T");
    52             numT--;
    53         }
    54         if(nume)
    55         {
    56             printf("e");
    57             nume--;
    58         }
    59         if(nums)
    60         {
    61             printf("s");
    62             nums--;
    63         }
    64         if(numt)
    65         {
    66             printf("t");
    67             numt--;
    68         }
    69     }
    70     return 0;
    71 }
    在这个国度中,必须不停地奔跑,才能使你保持在原地。如果想要寻求突破,就要以两倍现在速度奔跑!
  • 相关阅读:
    mysql排序
    MySQL命令行导出数据库
    os.path python使用遍历文件夹文件
    linux后台运行和关闭、查看后台任务
    WebDriver中自动识别验证码--Python实现
    一起学react (1) 10分钟 让你dva从入门到精通
    git命令大全
    jQuery中的100个技巧(译)
    Flow入门初识
    深入理解typescript的Functions
  • 原文地址:https://www.cnblogs.com/yuxiaoba/p/8507601.html
Copyright © 2011-2022 走看看