HDU 3783 ZOJ

http://acm.hdu.edu.cn/showproblem.php?pid=3783

 

 1 #include<stdio.h>
 2 #include<string.h>
 3 
 4 int main()
 5 {
 6     char j[110];
 7     while(scanf("%s",j),!(j[0]=='E'))
 8     {
 9      int m,i,a,b,c;
10      a=b=c=0;
11      m=strlen(j);
12      for(i=0;i<m;i++)
13      {
14          if(j[i]=='Z')
15          a++;
16          else if(j[i]=='O')
17          b++;
18          else 
19          c++;
20      }
21      for(i=0;i<m;i++)
22      {
23           if(a!=0)
24           { printf("Z");  a--;}
25           if(b!=0)
26           {  printf("O");  b--;}
27           if(c!=0)
28           {printf("J");  c--;}
29           if(!(a||b||c))
30           break;
31      }
32      printf("\n");
33     }
34 }

 

posted @ 2013-08-20 19:37  hpu张亚飞  阅读(163)  评论(0编辑  收藏  举报