| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1392 人关注过本帖
标题:The Dutch flag problem
只看楼主 加入收藏
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
 问题点数:0 回复次数:3 
The Dutch flag problem
Description

The Dutch flag problem is to rearrange an array of characters R, W,and B (red, white, and blue are the colors of the Dutch national flag) so that all the R’s come first, the W’s come next, and the B’s come last.
Design a linear and stable algorithm for this problem.

Input

two lines, the first line is total of numbers characters R,W and B ,and the numbers less than 500005
the second line is random characters R,W and B

Output

a line, all the R’s come first, the W’s come next, and the B’s come last.

Sample Input


10
WRRWRWBBRW

Sample Output


RRRRWWWWBB
搜索更多相关主题的帖子: Dutch flag problem The 
2008-11-13 17:04
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
得分:0 
怎么没人帮我啊?高手们啊!
收到的鲜花
  • multiple19022008-11-13 22:39 送鲜花  -1朵   附言:你自己看过
2008-11-13 17:13
ivapple
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2008-7-31
收藏
得分:0 
声明一个数组把输入的n个字符放进去,
再搞三个计数器,然后扫描一遍数组,
把R,W,B,的个数出来,比如分别有n1,n2,n3个
然后先输出n1个R,在输出n2个W,最后n3个B。

这样能行么?
2008-11-15 03:01
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
得分:0 
试试哈,应该可以,谢谢了朋友
2008-11-15 12:34
快速回复:The Dutch flag problem
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014801 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved