博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

<script>

window.onload=function(){


var   arr=[];

for(var i=1;i<1000001;i++)

{

      var stri= i.toString();

      for(var j=0;j<stri.length;j++)

      {                

                      if(stri.charAt(j)=='1')

                      {

                             arr.push(stri.charAt(j));

                       }

     }

};
var num=0
for(var i=0;i<arr.length;i++)

{

                   var  key=arr[i];

                 

                   for(var j=0; j<key.length; j++)

                   {

                             if(key.charAt(j)=='1')

                             {

                                        num++;

                               }

 

                     }

      }

alert(num);
}
 
</script>