一、 Java编程题
题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
class Test {
public static void main(String[] args) {
// s是初始高度,h是经过的高度,c 是第十次的高度
float s = 100; float h = 0; float c= 0;
for (int i = 1;i<=10;i++) {
// h等于每次初始高度+每次过后只用原高度的一半
h += s + s/2;
// s等于每次过后一半的高度
s= s/2;
}
// h等于第十次过后的高度减掉初始告诉
h = h -s;
System.out.println("第十次落地后经过多少" +h + "米");
// c等于第十次过后的高度
c = s ;
System.out.println("第十次:"+c);
}
}
二、 JavaScript编程题
查找字符串"sdddrtkjsfkkkasjdddj"中出现次数最多的字符和次数。
<script>
//定义一个str是sdddrtkjsfkkkasjdddj的字符串
var str="sdddrtkjsfkkkasjdddj";
//定义一个空的json对象
var json = {};
//循环str字符串
for (i=0;i<str.length ;i++ ){
// json对象中没有那个字符
if(!json[str[i]]){
//将字符添加到json对象中
json[str[i]] = str[i];
}else{
//在有的字符后面添加相同的字符
json[str[i]] += str[i];
}
}
// 定义max来接收出现最多次数的字符的次数
var max = 0;
// 定义strs 来接收出现最多次数的字符
var strs = "";
for(var str in json){
if(json[str].length>=max){
max = json[str].length;
strs = json[str];
}
}
// 打印
console.log(max);
console.log(strs);
三、 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
1、查询员工姓名及所做工作
select ename,title from emp;
2、 查询员工姓名及年薪
select ename,salary*12 as '年薪' from emp;
3、 查询工资大于4000的员工信息
select * from emp where salary > 4000;
4、 查询年薪大于20000的员工信息
select * from emp where (salary * 12) > 20000;
5、 查询没有奖金的员工
select ename from emp where bonus = null;
6、 查询工资大于3000同时有奖金的员工信息
select * from emp where salary > 3000 and bonus != null;
7、 查询工资大于3500但是小于5000的员工信息
select * from emp where salary between 3500 and 5000;
8、 查询编号是1001、1003、1004的员工信息
select * from emp where eid in(1001,1003,1004);
9、 查询编号不是1001、1003、1004的员工信息
select * from emp where eid not in(1001,1003,1004);
10、 查询员工姓名是3个字的员工信息
select * from emp where ename like "——";
11、 查询姓张的员工信息
select * from emp where ename like '张'%;
12、 查询出员工工资没有包含6和8的员工信息
select * from emp where salary not in (select salary from emp where eid in(6,8));
13、 按照工资由高到低查询员工信息
select * from emp gorup by salary desc;
14、 要求查询出101部门的所有雇员信息,查询的信息按照工资由高到低排序,如果工资相等,则按照雇佣日期由早到晚排序。
select * from dept where depart=101 gorup by salary, hiretime desc
15、 查询101部门有多少员工,每月平均发多少工资
select count(eid) as "多少员工",avg(salary) as "月薪" from emp where depart = 101;
16、 查询101部门的所有员工信息,并显示所在部门名称
select *,d.dname from emp as e left join dept as d on e.deprt = d.did where e.deprt = 101;
17、 查询1001员工的部门领导信息
select d.leader from dept as d left join emp as e on e.deprt = d.did where e.eid = 1001;
18、 查询部门员工数量,平均工资,最低工资及最低工资的员工姓名
select emp.depart,ename,t.s as "员工数量",t.a as "平均工资",t.m as "最低工资" from emp,(select depart,count(eid) as s,avg(salary) as a,min(salary) as m from emporder by depart) as t
where emp.depart=t.depart and emp.salary=t.m order by depart