标签:style blog ar color os sp java for on
描述
3
BBRRWBWRRR
RRRWWRWRB
RBRW
RRRRRWWBBB
RRRRRWWWB
RRWB
1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main { 5 public static void main(String[] args) { 6 Scanner scanner=new Scanner(System.in); 7 int T; 8 char sChar[]; 9 int i; 10 int R; 11 int W; 12 int B; 13 14 T=scanner.nextInt(); 15 while(true){ 16 if(T==0) 17 break; 18 T--; 19 20 sChar=scanner.next().toCharArray(); 21 22 R=0; 23 W=0; 24 B=0; 25 for(i=0;i<sChar.length;i++){ 26 if(sChar[i]==‘R‘) 27 R++; 28 else if(sChar[i]==‘W‘) 29 W++; 30 else 31 B++; 32 } 33 34 for(i=0;i<R;i++) 35 System.out.print("R"); 36 37 for(i=0;i<W;i++) 38 System.out.print("W"); 39 40 for(i=0;i<B;i++) 41 System.out.print("B"); 42 43 System.out.println(); 44 } 45 } 46 }
标签:style blog ar color os sp java for on
原文地址:http://www.cnblogs.com/zqxLonely/p/4133067.html