【PAT】B1043 輸出PATest(20 分)
阿新 • • 發佈:2018-08-18
test space using names break namespace turn int char
/* */ #include<stdio.h> #include<algorithm> #include<string.h> #include<ctype.h> using namespace std; int main(){ char temp; int P,A,T,e,s,t; P=A=T=e=s=t=0; while(scanf("%c",&temp)!=EOF){ switch(temp){ case ‘P‘: P++; break; case ‘A‘: A++; break; case ‘T‘: T++; break; case ‘e‘: e++; break; case ‘s‘: s++; break; case ‘t‘: t++; break; } } while(P!=0||A!=0||T!=0||e!=0||s!=0||t!=0){ if(P!=0){ printf("P"); P--; } if(A!=0){ printf("A"); A--; } if(T!=0){ printf("T"); T--; } if(e!=0){ printf("e"); e--; } if(s!=0){ printf("s"); s--; } if(t!=0){ printf("t"); t--; } } return 0; }
【PAT】B1043 輸出PATest(20 分)