我正在尝试编写一个C++程序,它从用户那里获取以下输入来构造矩形(2到5之间):高度,宽度,x-pos,y-pos.所有这些矩形将平行于x轴和y轴存在,即它们的所有边都将具有0或无穷大的斜率.
我试图实现这个问题中提到的但我没有太多运气.
我目前的实现如下:
// Gets all the vertices for Rectangle 1 and stores them in an array -> arrRect1
// point 1 x: arrRect1[0], point 1 y: arrRect1[1] and so on...
// Gets all the vertices for Rectangle 2 and stores them in an array -> arrRect2
// rotated edge of point a, rect 1
int rot_x, rot_y;
rot_x = -arrRect1[3];
rot_y = arrRect1[2];
// point on rotated edge
int pnt_x, pnt_y;
pnt_x = arrRect1[2];
pnt_y = arrRect1[3]; …Run Code Online (Sandbox Code Playgroud) 该表用于存储会话(事件):
CREATE TABLE session (
id int(11) NOT NULL AUTO_INCREMENT
, start_date date
, end_date date
);
INSERT INTO session
(start_date, end_date)
VALUES
("2010-01-01", "2010-01-10")
, ("2010-01-20", "2010-01-30")
, ("2010-02-01", "2010-02-15")
;
Run Code Online (Sandbox Code Playgroud)
我们不希望范围之间发生冲突.
假设我们需要在2010-01-05到2010-01-25之间插入一个新会话.
我们想知道冲突的会话.
这是我的查询:
SELECT *
FROM session
WHERE "2010-01-05" BETWEEN start_date AND end_date
OR "2010-01-25" BETWEEN start_date AND end_date
OR "2010-01-05" >= start_date AND "2010-01-25" <= end_date
;
Run Code Online (Sandbox Code Playgroud)
结果如下:
+----+------------+------------+
| id | start_date | end_date |
+----+------------+------------+
| 1 | 2010-01-01 | …Run Code Online (Sandbox Code Playgroud) 表格1
id int pk
searchdate datetime
amount float
Run Code Online (Sandbox Code Playgroud)
表1的数据
id searchdate amount
1 2014-02-05 100
2 2014-02-02 245
3 2014-02-11 344
Run Code Online (Sandbox Code Playgroud)
我想要data between 2014-02-01 to 2014-02-10,但我想要的datetime picker是"01-02-2014" (dd-mm-yyyy format).请帮我在查询之间创建MySQL.