原创 字符串String=“adadfdfseffserfefsefseetsdg”,找出里面出现次数最多的字母和出现的次数.

2006-6-22 09:42 2226 10 6 分类: MCU/ 嵌入式
<script>
var str ="adadfdfseffserfefsefseeffffftsdg";
var maxLength = 0
var result = ''

while( str != '' )
{
      oldStr = str
      getStr = str.substr(0,1)
      eval("str = str.replace(/"+getStr+"/g,'')")


      if( oldStr.length-str.length > maxLength )
      {
            maxLength =  oldStr.length-str.length
            result = getStr + "=" + maxLength
      }
}
      alert(result)


</script>


432394.html

tohen 2006-06-22 09:42 发表评论
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
我要评论
0
10
关闭 站长推荐上一条 /3 下一条