利用JS生成01010101……长度可控的序列
2024-10-15 04:00:37
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 就好了!
最新文章
- Python学习之day2
- 转 CSS hack:针对IE6,IE7,firefox显示不同效果
- 利用WiFi钓鱼法追邻居漂亮妹纸
- HDU 1532 Drainage Ditches 排水渠(最大流,入门)
- LA 3904
- Netbeans8下 Weblogic EJB案例
- (转)iOS7界面设计规范(12) - UI基础 - 品牌
- JAVA Metrics 度量工具使用介绍
- PCI-X总线
- ASP.NET MVC4中使用NHibernate
- oracle 写入txt
- salesforce 零基础学习(六十六)VF页面应善于使用变量和函数(二)常用函数的使用
- PL/SQL + Oracle客户端 配置记录
- Appium环境搭建(python)
- CSc 352 (Spring 2019): Assignment
- PreparedStatement 与 Statement 的区别
- MongoExport后的负载均衡问题查询及解决:can&#39;t accept new chunks because there are still 2 deletes from previous migration
- python第六十天-----RabbitMQ
- 使用Holer外网SSH访问内网(局域网)Linux系统
- Real Time Rendering 1
热门文章
- difference bewteen *args and **args in python?
- 转一篇介绍Web session概念的文章
- Swift 提示:Initialization of variable was never used consider replacing with assignment to _ or removing it
- 优雅的数组降维——Javascript中apply方法的妙用
- 初识ZooKeeper
- hdu 5071(2014鞍山现场赛B题,大模拟)
- JavaScript预解析1
- DataTable.RowFilter 用法
- XCode6 生成prefix.pch文件
- C# 的EF框架怎么连接Oracle数据库