每日一练20171020

一、 Java编程题

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

double height = 100;

double sum = 0;

for(int i = 1; i <=10; i++){

sum += height/Math.pow(2, i-1)*2;

}

double totalSum = sum-100;

double totalHeight = (double) (height/Math.pow(2, 10));

System.out.println("第10次落地,共经过了"+totalSum +"米");

System.out.println("第10次反弹"+totalHeight+"米");

二、 JavaScript编程题

查找字符串"sdddrtkjsfkkkasjdddj"中出现次数最多的字符和次数。

 <script type="text/javascript">

var str = "sdddrtkjsfkkkasjdddj";

var arr = [];

//循环遍历字符串

for (var i = 0; i < str.length; i++) {

var index = -1;

var j = 0;

//找每一个字符

do {

index = str.indexOf(str[i], index + 1);

if (index != -1) {

j++;

}

}while (index != -1);

arr[j] = str[i];

}

console.log(arr);

console.log("次数最多的字符是" + arr[arr.length - 1]);

console.log("次数是" + (arr.length - 1));

  </script>

三、 SQL编程题

员工表emp:员工编号eid,姓名ename,工作职位title,雇佣日期hiretime,工资salary,奖金bonus,部门 depart
部门表dept:部门编号did,名称dname,部门领导leader

员工数据: 
1001,’张三’,’销售’,’1999-12-1’,3000.0,1100.0,’102’ 
1002,’李四’,’研发员’,’1998-2-11’,3500.0,null,’101’ 
1003,’王五’,’研发员’,’2001-1-15’,4000.0,null,’101’ 
1004,’赵六’,’美工’,’2001-12-1’,4000.0,null,’101’ 
1005,’武六奇’,’研发员’,’2001-7-1’,5500.0,null,’101’ 
1006,’齐八九’,’销售’,’2001-6-16’,3000.0,1500.0,’102’ 
1007,’钱多多’,’经理’,’2009-11-10’,6500.0,2000.0,’102’ 
1008,’张一一’,’销售’,’2007-12-10’,3800.0,1000.0,’102’ 
1009,’李丽丽’,’研发员’,’1999-8-19’,4500.0,null,’101’ 
1010,’王旺旺’,’销售’,’1999-9-1’,3600.0,1600.0,’102’ 
1011,’赵有才’,’经理’,’1999-4-30’,7000.0,1800.0,’101’ 
1012,’李雷’,’出纳’,’2007-10-10’,5000.0,500.0,’103’ 
1013,’韩梅’,’会计’,’2005-3-1’,6600.0,1000.0,’103’ 
1014,’张向阳’,’经理’,’2002-6-1’,7000.0,1500.0,’103’ 
1015,’李向东’,’销售’,’2004-5-1’,4300.0,1000.0,’102’

部门数据
‘101’,’研发部’,1007 
‘102’,’销售部’,1011 
‘103’,’财务部’,1014

-- 查询员工姓名及所做工作

select ename,title from emp;

-- 查询员工姓名及年薪

select ename as "姓名",salary*12 as "年薪" from emp;

-- 查询工资大于4000的员工信息

select * from emp where salary>4000;

-- 查询年薪大于20000的员工信息

select * from emp where salary*12 > 20000;

-- 查询没有奖金的员工

select * from emp where bonus is null;

-- 查询工资大于3000同时有奖金的员工信息

select * from emp where salary>3000 and bonus is not null

-- 查询工资大于3500但是小于5000的员工信息

select * from emp where salary>3500 and salary<5000;

-- 查询编号是1001、1003、1004的员工信息

select * from emp where eid in(1001,1003,1004);

-- 查询编号不是1001、1003、1004的员工信息

select * from emp where eid not in(1001,1003,1004);

-- 查询员工姓名是3个字的员工信息

select * from emp where ename like "___";

-- 查询姓张的员工信息

select * from emp where ename like "张%";

-- 查询出员工工资没有包含6和8的员工信息

select * from emp where salary not like '%6%' and salary not like '%8%';

-- 按照工资由高到低查询员工信息

select * from emp order by salary desc;

-- 要求查询出101部门的所有雇员信息,查询的信息按照工资由高到低排序,如果工资相等,则按照雇佣日期由早到晚排序。

select * from emp where depart=101 order by salary desc,hiretime asc;

-- 查询101部门有多少员工,每月平均发多少工资

select count(*) as "员工数量",avg(salary) as "平均工资" from emp where depart=101;

-- 查询101部门的所有员工信息,并显示所在部门名称

select * from emp

left join dept

on emp.depart=dept.did

where emp.depart=101;

-- 查询1001员工的部门领导信息

select * from emp

where eid=(

select dept.leader

from dept

left join emp

on emp.depart=dept.did

where emp.eid=1001);

 

-- 查询部门员工数量,平均工资,最低工资及最低工资的员工姓名

SELECT depart '部门',COUNT(eid) '员工数量',AVG(salary) '平均工资',MIN(salary) '最低工资',n.name '最低工资姓名'

FROM emp ,

(select depart dt,GROUP_CONCAT(ename) name from emp where salary in (select MIN(salary) from emp GROUP BY depart)GROUP BY depart) AS n

where emp.depart = n.dt

GROUP BY depart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值