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

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

    输入格式:

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

    输出格式:

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

    输入样例:

    redlesPayBestPATTopTeePHPereatitAPPT
    

    输出样例:

    PATestPATestPTetPTePePee
    
     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<stdlib.h>
     4 #include<ctype.h>
     5 #include<math.h>
     6 
     7 int main(){
     8     char a[10010];
     9     gets(a);
    10     int lena = strlen(a);
    11     int P,A,T,e,s,t;
    12     P=0,A=0,T=0,e=0,s=0,t=0;
    13     for(int i=0;i<lena;i++){
    14         if(a[i]=='P')
    15             P++;
    16         if(a[i]=='A')
    17             A++;
    18         if(a[i]=='T')
    19             T++;
    20         if(a[i]=='e')
    21             e++;
    22         if(a[i]=='s')
    23             s++;
    24         if(a[i]=='t')
    25             t++;
    26     }
    27     while(P||A||T||e||s||t){
    28         if(P){
    29             printf("P");
    30             P--;
    31         }
    32         if(A){
    33             printf("A");
    34             A--;
    35         }
    36         if(T){
    37             printf("T");
    38             T--;
    39         }
    40         if(e){
    41             printf("e");
    42             e--;
    43         }
    44         if(s){
    45             printf("s");
    46             s--;
    47         }
    48         if(t){
    49             printf("t");
    50             t--;
    51         }
    52             
    53     }
    54 } 
  • 相关阅读:
    DOM
    js中字符串常规操作
    placeholer改变默认灰色
    css重置reset.css
    倒计时跳转
    手机中间四位用*代替
    animation
    过渡
    flex布局
    css3几个新属性
  • 原文地址:https://www.cnblogs.com/lolybj/p/6238133.html
Copyright © 2011-2022 走看看