没有方向,不叫发展 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; }


代码:




你可能感兴趣的:(职业)