JavaScript 编程题
输入某年某月某日,判断这一天是这一年的第几天?
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
//弹出年、月、日输入框,声明年鱼儿,并赋值
var y =parseInt(prompt("请输入你的出生年份"));
var m = parseInt(prompt("请输入你的出生月份"));
var d =parseInt(prompt("请输入你的出生日期"));
//月
//求各月份数字之和
var getMonth=new Array(31,28,31,30,31,30,31,31,30,31,30);
var sum1=0,i;
for(i=0;i<m-1;i++){
sum1+=getMonth[i]
}
//年
//判断年是否为闰年,是且大于2月份加一
if(( y%400 ==0||(y % 4 == 0&& y%100 !=0))&& m > 2){
sum=sum1 + d +1;
document.write("该天为一年中的第"+sum+"天");
}else{
sum=sum1+d;
document.write("该天为一年中的第"+sum+"天");
}
</script>
</body>
</html>
MySQL 编程题
在名为商品库的数据库中包含有商品规格表 Content 和商品特性表 Property,它们的定义分别为:
Content(Code varchar(50),Class varchar(20),Price double,Number int)
Property(Code varchar(50),Place varchar(20),Brand varchar(50))
(1)写出下面查询语句的作用;
SELECT Distinct Brand FROM Property;
答:从表Property查询不重复的Brand数据
(2)从商品规格表中查询出每类商品的最高单价
SELECT MAX(price) AS "最高价格" FROM Content
WHERE GROUP BY class;
(3) 从商品规格表中查询出同一类商品多于一种的所有分类名
SELECT class,code FROM Content
GROUP BY class
HAVING COUNT(number) > 1;
Java 编程题
打印出如下图案(菱形) 。
*
***
*****
*******
*****
***
*
package practice;
public class Demo {
public static void main(String[] args) {
Xinghao lx = new Xinghao();
lx.printLingXing();
}
}
class Xinghao {
public void printLingXing() {
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= 4 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= 2 * i - 1; k++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= 7 - 2 * i; k++) {
System.out.print("*");
}
System.out.println();
}
}
}