每日练习2017-10-31

来源:互联网 发布:电气设计软件有哪些 编辑:程序博客网 时间:2024/05/19 20:37

2017-10-31

JavaScript

下面两个函数的返回值是一样的吗?为什么?

function foo1(){  return {      bar: "hello"  };}function foo2(){  return   {      bar: "hello"  };}

答案:
返回对象{}他留有一个大括号跟return在同一行 返回的是object
没在return同一行所以返回的是undefined
第二个return在浏览器解析时 会自动添加 分号

MySQL

用一条 SQL 语句,查询出每门课都大于 80 分的学生姓名。
表名 student_score

name course score 张三 语文 81 张三 数学 75 李四 语文 76 李四 数学 90 王五 语文 81 王五 数学 100 王五 英语 90

答案:

select distinct name from user where name not in (select distinct name from user where score<=80); 

Java

一球从 100 米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第 10 次落地时,共经过多少米?第 10 次反弹多高?
答案:

    public static void main(String[] args){        double x =100;        for (int i=1;i<=10 ;i++ ){            double a = Math.pow(2,i);            double t = 100/a;            x =x + (2*t);         System.out.println(t);        }        System.out.println("========");        System.out.println(x);    }