function ab(d){
var a = [];
var x = 1 ;
for (var i = 0; i < d; i++) {
if (x == 0) {
x = x + 1;
} else {
x = x -1;
}
a.push(x);
}
alert(a.toString());
}
var d = 8 ;
ab(d);

函数名随意取个ab,参数d。

如果需要改为10101010……这样的序列就把第3行x = 1 改为x = 0 就好了!

最新文章

  1. Python学习之day2
  2. 转 CSS hack:针对IE6,IE7,firefox显示不同效果
  3. 利用WiFi钓鱼法追邻居漂亮妹纸
  4. HDU 1532 Drainage Ditches 排水渠(最大流,入门)
  5. LA 3904
  6. Netbeans8下 Weblogic EJB案例
  7. (转)iOS7界面设计规范(12) - UI基础 - 品牌
  8. JAVA Metrics 度量工具使用介绍
  9. PCI-X总线
  10. ASP.NET MVC4中使用NHibernate
  11. oracle 写入txt
  12. salesforce 零基础学习(六十六)VF页面应善于使用变量和函数(二)常用函数的使用
  13. PL/SQL + Oracle客户端 配置记录
  14. Appium环境搭建(python)
  15. CSc 352 (Spring 2019): Assignment
  16. PreparedStatement 与 Statement 的区别
  17. MongoExport后的负载均衡问题查询及解决:can&#39;t accept new chunks because there are still 2 deletes from previous migration
  18. python第六十天-----RabbitMQ
  19. 使用Holer外网SSH访问内网(局域网)Linux系统
  20. Real Time Rendering 1

热门文章

  1. difference bewteen *args and **args in python?
  2. 转一篇介绍Web session概念的文章
  3. Swift 提示:Initialization of variable was never used consider replacing with assignment to _ or removing it
  4. 优雅的数组降维——Javascript中apply方法的妙用
  5. 初识ZooKeeper
  6. hdu 5071(2014鞍山现场赛B题,大模拟)
  7. JavaScript预解析1
  8. DataTable.RowFilter 用法
  9. XCode6 生成prefix.pch文件
  10. C# 的EF框架怎么连接Oracle数据库