Skip to content

Commit 934713b

Browse files
committed
提交复习表algorithm002#25
1 parent 5096147 commit 934713b

File tree

2 files changed

+145
-2
lines changed

2 files changed

+145
-2
lines changed

Week_01/id_25/NOTE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
![复习表](http://ww1.sinaimg.cn/large/466e120ely1g3vboe39o3j216a0pztaq.jpg)
2323

2424
4 在学习笔记里 主要提及宏观上的学习领悟
25-
关于具体的题解思路 都详尽的写在题目里的注解里了
25+
关于具体的题解思路 都详尽的写在题目里的注解里了
2626

27-
5 Review
27+
5 分享一下记忆曲线复习表 即是TaskView.html
28+
直接浏览器打开就能用 里面包含一段斐波那契递归函数呦
29+
30+
6 Review
2831
总体感触 用什么语言的都有 精彩纷呈
2932
5.1 LeetCode_242_18.java
3033
优点

Week_01/id_25/TaskView.html

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
<script src="jquery-3.4.1.min.js"></script>
7+
<style>
8+
/*table,table tr th, table tr td { border:1px solid #0094ff; }*/
9+
/*table { width: 200px; min-height: 25px; line-height: 25px; text-align: center; border-collapse: collapse;}*/
10+
table {
11+
height: 200px;
12+
width: 1600px;
13+
border: 2px solid forestgreen;
14+
}
15+
16+
th {
17+
background: cornflowerblue;
18+
border: 1px solid;
19+
}
20+
21+
td {
22+
border: 1px solid;
23+
}
24+
25+
tr:nth-child(2n) {
26+
/*background: #00CCCC;*/
27+
}
28+
29+
tr td:nth-child(1) {
30+
/*background: #FFCCCC;*/
31+
}
32+
33+
.job {
34+
background: #FFCCCC;
35+
}
36+
</style>
37+
</head>
38+
<body>
39+
<table id="table">
40+
<!--<thead>-->
41+
<!--<tr class="center">-->
42+
<!--<th class="col-xs-3 center">名称</th>-->
43+
<!--<th class="col-xs-3 center">创建时间</th>-->
44+
<!--</tr>-->
45+
<!--</thead>-->
46+
<!--<tbody id="tbody">-->
47+
<!--<tr class="center">-->
48+
<!--<td class="col-xs-3 center">1</td>-->
49+
<!--<td class="col-xs-3 center">2</td>-->
50+
<!--</tr>-->
51+
<!--</tbody>-->
52+
</table>
53+
<script>
54+
$(function () {
55+
// test
56+
getfib().forEach(function (val, index) {
57+
console.log(val, index);
58+
});
59+
60+
schedule(31);
61+
});
62+
63+
function schedule(days) {
64+
var fib = getfib();
65+
var matrix = new Array(); // 先声明一维
66+
for (var i = 0; i < days; i++) { // 一维长度
67+
matrix[i] = new Array(); // 再声明二维
68+
for (var j = 0; j < days; j++) { // 二维长度
69+
var practice = contains(fib, j - i + 1);
70+
matrix[i][j] = practice ? 1 : 0;
71+
}
72+
}
73+
var $table = $("#table");
74+
var $tr = $("<tr></tr>");
75+
var $th = $("<th>题目</th>");
76+
$tr.append($th);
77+
for (var i = 0; i < days; i++) {
78+
// var title = i < 9 ? "0" + (i + 1) : (i + 1);
79+
var title = "<input value='number'/>";
80+
var $th = $("<th>" + title + "</th>");
81+
$tr.append($th);
82+
}
83+
$table.append($tr);
84+
for (var i = 0; i < days; i++) {
85+
var $table = $("#table");
86+
var $tr = $("<tr></tr>");
87+
var $th = $("<th>第" + (i + 1) + "天</th>");
88+
$tr.append($th);
89+
for (var j = 0; j < days; j++) {
90+
// var val = matrix[j][i] === 0 ? 0 : j === 0 ? 1 : j;
91+
var val = matrix[j][i] === 0 ? 0 : j === 0 ? 1 : j;
92+
var htmlClass = val !== 0 ? "class='job'" : "";
93+
var id = "i" + i + "j" + j;
94+
var input = val !== 0 ? "<input type='checkbox' onclick='check(" + id + ")'/>" : matrix[j][i];
95+
// var $td = $("<td style='color: deepskyblue;' " + htmlClass + ">" + matrix[j][i] + "</td>");
96+
var $td = $("<td id='" + id + "' style='color: deepskyblue;' " + htmlClass + ">" + input + "</td>");
97+
$tr.append($td);
98+
}
99+
$table.append($tr);
100+
}
101+
}
102+
103+
function contains(set, value) {
104+
return set.has(value);
105+
}
106+
107+
function getfib() {
108+
var res = new Set();
109+
var n = 0;
110+
var calc = 0;
111+
while (calc < 30) {
112+
calc = helper(n++);
113+
res.add(calc);
114+
}
115+
return res;
116+
}
117+
118+
function helper(n) {
119+
if (n === 0) {
120+
return 1;
121+
}
122+
if (n < 4) {
123+
return n;
124+
}
125+
return helper(n - 1) + helper(n - 2);
126+
}
127+
128+
function check(id) {
129+
console.log(id);
130+
var style = id.getAttribute('style');
131+
if (style === 'background:forestgreen;') {
132+
id.setAttribute('style', 'background:#FFCCCC;');
133+
} else {
134+
id.setAttribute('style', 'background:forestgreen;');
135+
}
136+
}
137+
138+
</script>
139+
</body>
140+
</html>

0 commit comments

Comments
 (0)