20171114

来源:互联网 发布:里欧万塔 知乎 编辑:程序博客网 时间:2024/06/05 19:04

JavaScript 编程题
输入某年某月某日,判断这一天是这一年的第几天?


<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>


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;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);}}
原创粉丝点击