没有方向,不叫发展 No Directions, No Development

又到了年末,总结、规划少不了。

简单点,8个字:

没有方向,不叫发展

No Directions, No Development


把后面的代码保存成html文件,然后用浏览器打开,会看到类似以下结果:

从 20 岁到 40 岁,

集中度为 0.8
增值达到 10.9倍,
最高 46.0
最低 0.10

这意味着什么,就不用说了。


代码片:

// 没有方向,不叫发展 2014-1-26 10:24:19
// No Directions, No Development. 2014-1-26 10:25:22
var amount = 1;
var focus = 1;
var ageBegin = 20;
// var ageEnd = 35;
var ageEnd = 40;
var age = 20;

var focusPercentage = 0;
var increasePercentage = 1.2;
var decreasePercentage = 0.9;

var focusNum = 0;
var amountTop = 1;
var amountBottom = 1;

// Calculating:
age = ageBegin;
while(age <= ageEnd){
	focus = getRandFocus();

	if(focus){
		focusNum++;
		amount = amount*increasePercentage;
	}else{
		amount = amount*decreasePercentage;
	}

	amountTop *= increasePercentage;
	amountBottom *= decreasePercentage;

	age++;
}

focusPercentage = focusNum/(ageEnd - ageBegin);

focusPercentage = focusPercentage.toString().substr(0,5);
amount = amount.toString().substr(0,4);
amountTop = amountTop.toString().substr(0,4);
amountBottom = amountBottom.toString().substr(0,4);


document.write("从 " + ageBegin + " 岁到 " + ageEnd + " 岁,
集中度为 " + focusPercentage + ",
增值达到 " + amount + "倍,
最高 " + amountTop + "
最低 " + amountBottom); function getRandFocus(){ var rand = Math.random(); var randInt = Math.floor(rand*100000); var result = randInt%2; return result; }


代码:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript">

// 没有方向,不叫发展 2014-1-26 10:24:19
// No Directions, No Development. 2014-1-26 10:25:22
var amount = 1;
var focus = 1;
var ageBegin = 20;
// var ageEnd = 35;
var ageEnd = 40;
var age = 20;

var focusPercentage = 0;
var increasePercentage = 1.2;
var decreasePercentage = 0.9;

var focusNum = 0;
var amountTop = 1;
var amountBottom = 1;

// Calculating:
age = ageBegin;
while(age <= ageEnd){
	focus = getRandFocus();

	if(focus){
		focusNum++;
		amount = amount*increasePercentage;
	}else{
		amount = amount*decreasePercentage;
	}

	amountTop *= increasePercentage;
	amountBottom *= decreasePercentage;

	age++;
}

focusPercentage = focusNum/(ageEnd - ageBegin);

focusPercentage = focusPercentage.toString().substr(0,5);
amount = amount.toString().substr(0,4);
amountTop = amountTop.toString().substr(0,4);
amountBottom = amountBottom.toString().substr(0,4);


document.write("从 " + ageBegin + " 岁到 " + ageEnd + " 岁,<br />集中度为 <strong>" + focusPercentage + "</strong>, <br />增值达到 " + amount + "倍,<br />最高 " + amountTop + "<br />最低 " + amountBottom);

function getRandFocus(){
	var rand = Math.random();
	var randInt = Math.floor(rand*100000);
	var result = randInt%2;
	return result;
}

</script>


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值