一、Java 编程题
int a = 10,int b = 20,请实现这两个数的值的交换(变成int a = 20,int b = 10),要求写3种或3种以上的实现方式
public class Test {
public static void main(String[] args)
{
int a = 10,b = 20;
/* int temp = a;
a = b;
b = temp;*/
/* int temp = a + b;
a = temp - a;
b = temp - a;*/
a = a^b;
b = a^b;
a = a^b;
System.out.println("a:"+a);
System.out.println("b:"+b);
}
}
二、MySql题
请描述MySql从安装到配置的全部详细过程(确保一台新电脑可以顺利使用mysql)
1.去官网下载Mysql配置版
2.将Mysql注册到系统服务中
3.将Mysql的bin目录配置到系统环境变量path中
4.通过命令mysql -uroot -p进入数据库
三、JS题目
请做一个年,月,日的联动菜单
<body>
年<select id="year" οnchange="change();">
</select>
月<select id="month" οnchange="change();">
</select>
日<select id="day">
</select>
<script>
var year = document.getElementById("year");
var month = document.getElementById("month");
var day = document.getElementById("day");
for(var i = 1980;i<=new Date().getFullYear();i++){
var option = document.createElement("option");
option.setAttribute("value",i);
option.innerHTML=i;
year.appendChild(option);
}
for(var i = 1;i<=12;i++){
var option = document.createElement("option");
option.setAttribute("value",i);
option.innerHTML=i;
month.appendChild(option);
}
for(var i = 1;i<=31;i++){
var option = document.createElement("option");
option.setAttribute("value",i);
option.innerHTML=i;
day.appendChild(option);
}
//判断是否是闰年
function isLeapYear(year){
var flag = false;
if((year%4==0&&year%100!=0)||year%400==0){
flag = true;
}
return flag;
}
//判断某年某月对应的天数
function getDay(year,month){
var num = 0;
switch(month){
case "1":
case "3":
case "5":
case "7":
case "8":
case "10":
case "12": num = 31;
break;
case "4":
case "6":
case "9":
case "11": num = 30;
break;
case "2":if(isLeapYear(year)){
num = 29;
}else{
num = 28;
}
break;
}
return num;
}
function change(){
//获取当前年,月
var currYear = year.options[year.selectedIndex].value;
var currMonth = month.options[month.selectedIndex].value;
var days = getDay(currYear,currMonth);
day.innerHTML = "";
for(var i = 1;i<=days;i++){
var option = document.createElement("option");
option.setAttribute("value",i);
option.innerHTML=i;
day.appendChild(option);
}
}
</script>
</body>
每日一练-20171114
最新推荐文章于 2023-08-29 13:24:23 发布