Last active
August 29, 2015 14:02
-
-
Save chen37106/c5cca8fd772d6dbf2d7b to your computer and use it in GitHub Desktop.
js1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//摄氏度转换为华氏度 | |
var c=39; | |
var f=32+c*1.8; | |
console.log(c+"摄氏度等于"+f+"华氏度"); | |
//交换两个变量的值 | |
var alice=8; | |
var bob=5; | |
var t=alice; | |
alice=bob; | |
bob=t; | |
console.log("alice有"+alice+"个苹果,bob有"+bob+"个苹果。"); | |
//js作为计算器 | |
//使用 JS 计算一年有多少秒。简单的乘法。 | |
var y=365*24*60*60; | |
var ly=366*24*60*60; | |
console.log("非闰年的一年有"+y+"秒,闰年的一年有"+ly+"秒"); | |
//进一步,假设自己写一行代码需要17秒,那么一年能写多少行代码? | |
//愚蠢的人类需要吃饭睡觉休息,不能像高阶生物那样全年不休地写代码。 | |
//请估算在有休息的情况下一名普通人类(以自己为例)能写多少代码。 | |
var y=302*3*60*60;//按996计算 | |
var r=y/17; | |
var n=Math.floor(r);//向下取整 | |
console.log("正常人一年吐了血能写"+n+"行代码"); | |
//上网搜索 Linux 内核的代码行数。计算一下一个人独立完成 Linux 内核需要几年? | |
var l=10000000; | |
var y=302*3*60*60; | |
var r=y/17; | |
var n=Math.floor(r); | |
var t=Math.ceil(l/n);//向上取整 | |
console.log("一个人独立完成linux内核需要"+t+"年"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment