20180705 Day 010

一、JavaScript编程题

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

<html>
<head>
<meta charset="UTF-8">
<title>测试</title>
</head>
<body >
   <script>
    var a = parseInt(prompt("请输入你的出生年份"));
    var b = parseInt(prompt("请输入你的出生月份"));
    var c = parseInt(prompt("请输入你的出生日份"));
        var endDate = new Date (a, b - 1, c);
        var startDate = new Date(a,0,0);
        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 编程题

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


   *
  ***
 *****
*******
 *****
  ***
   *

public class Pattern {
public static void print(int n) {
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/m19950519/article/details/80925723