1043 output PATest, C

Summary explanations directory

#include <stdio.h>
int main()
{
    char a[10001]={0},b[10001]={0},c[10001]={0};
    int i=0,j=0,x=0,z=0;

    scanf("%s",a);
    while(a[i])
    {
        if(a[i]=='P' || a[i]=='A' || a[i]=='T' || a[i]=='e'|| a[i]=='s' || a[i]=='t')
        {b[j] = a[i]; j++;}
        i++;
    }

    x=j-1;
    while(x!=(-1))
    {
        i=0;
        while(i<=x)
        {
            if(b[i]=='P')
                {c[z] = b[i];z++;b[i]=b[x];x--;break;}
            i++;  
        }
        i=0;
        while(i<=x)
        {
            if(b[i]=='A')
                {c[z] = b[i];z++;b[i]=b[x];x--;break;}
            i++;  
        }
        i=0;
        while(i<=x)
        {
            if(b[i]=='T')
                {c[z] = b[i];z++;b[i]=b[x];x--;break;}
            i++;  
        }
        i=0;
        while(i<=x)
        {
            if(b[i]=='e')
                {c[z] = b[i];z++;b[i]=b[x];x--;break;}
            i++;  
        }
        i=0;
        while(i<=x)
        {
            if(b[i]=='s')
                {c[z] = b[i];z++;b[i]=b[x];x--;break;}
            i++;  
        }
        i=0;
        while(i<=x)
        {
            if(b[i]=='t')
                {c[z] = b[i];z++;b[i]=b[x];x--;break;}
            i++;  
        }
    }

    printf("%s",c);
    return 0;
}
Published 44 original articles · won praise 0 · Views 867

Guess you like

Origin blog.csdn.net/weixin_43916400/article/details/104585405