编程素养010

JavaScript编程题

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>根据年月日求一年中那一天</title>
</head>
<body>
<script>

	// 弹出年、月、日输入框,声明年月日,并赋值
	var y = parseInt(prompt("请输入你的出生年份"));
	var m = parseInt(prompt("请输入你的出生月份"));
	var d = parseInt(prompt("请输入你的出生日期"));

	// 输入的时间作为终止时间,前一年的最后一天作为起始时间。
	// new Date(year,month,date) ,month 的值域为 0~11,0 代表 1 月,11 表代表 12月; 
	var endDate = new Date(y, m - 1, d);
	// date 从 1 开始,若写为 0,则向前一天
	var startDate = new Date(y, 0, 0);

	// 两者做差,计算出间隔时间。new Date() 参与计算会自动转换为从 1970.1.1 开始的毫秒数
	var days = (endDate - startDate) / 1000 / 60 / 60 / 24;

	document.write("该天为一年中的第" + days + "天");
		
</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表中查询出所有不同的品牌
(2)从商品规格表中查询出每类商品的最高单价
SELECT Class,max(Price) FROM Content GROUP BY Class;
(3) 从商品规格表中查询出同一类商品多于一种的所有分类名
SELECT Class FROM Content GROUP BY Class HAVING COUNT(Class)>1;

java编程题

打印出如下图案(菱形) 。

   *
  ***
 *****
*******
 *****
  ***
   *
package test;

/**
 * @author CUI
 *
 */
public class Tl9 {
	public static void print(int n) {
		// 先把图形分成两部分来看待,前四行一个规律,后三行一个规律,利用双重 for 循环,第一层控制行,第二层控制列。
		// 前四行
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n - 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 < n; i++) {
			
			for (int j = 1; j <= i; j++) {
				System.out.print(" ");
			}
			for (int k = 1; k <= 2*(n-i) - 1; k++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}

	public static void main(String[] args) {
		print(4);
	}
}

猜你喜欢

转载自blog.csdn.net/ShanGe9527/article/details/83314512