{"id":131529,"student_id":2002,"content":"// 1.1\n// console.log(f(2,3));\n// function f(a, b) {\n// if (b == 0)\n// return 1;\n// if (b \u003e= 1)\n// return a*f(a, b-1);\n// }\n// --------------------------------------------------------------------------\n// 2.1\n// var arr = [2,5,3,1,4];\n// console.log(\"排序前:\"+arr);\n// bubSort();\n// console.log(\"排序後:\"+arr);\n// function selsctSort() {\n// for (var k = 0; k \u003c arr.length; k++) {\n// min = k;\n// for (var i = k; i \u003c arr.length; i++) {\n// if (arr[min] \u003e arr[i]) {\n// min = i;\n// }\n// }\n// var temp = arr[k];\n// arr[k] = arr[min];\n// arr[min] = temp;\n\n// }\n// }\n// function bubSort() {\n// for (var k = 0; k \u003c arr.length; k++) {\n// for (var i = 0; i \u003c arr.length - k; i++) {\n// if (arr[i] \u003e arr[i+1]) {\n// var temp = arr[i];\n// arr[i] = arr[i+1];\n// arr[i+1] = temp;\n// }\n// }\n// }\n// }\n// --------------------------------------------------------------------------\n// 2.2\n// var arr = [];\n// var num = 6;\n// createArr();\n// shuffler();\n// console.log(arr);\n// function shuffler() {\n// var ran = Math.floor(Math.random() * num);\n// var ran2 = Math.floor(Math.random() * num);\n// var temp = arr[ran];\n// arr[ran] = arr[ran2];\n// arr[ran2] = temp;\n// }\n// --------------------------------------------------------------------------\n// 2.3\n// function createArr() {\n// for (var i = 0; i \u003c num; i++) {\n// arr.push(i);\n// }\n// }\n// --------------------------------------------------------------------------\n// 3.1\n// var arr = [3, 5, 2, 1, 4, 6];\n// console.log(\"排序前\" + arr);\n// insertSort();\n// console.log(\"排序後\" + arr);\n// function insertSort() {\n// for (var i = 0; i \u003c arr.length; i++) {\n// for (var k = 0; k \u003c i; k++) {\n// if (arr[i] \u003c arr[k]) {\n// arr.splice(k, 0, arr[i]);\n// arr.splice(i+1, 1);\n// break;\n// }\n// }\n// }\n// }\n// --------------------------------------------------------------------------\n// 4.1\n// var input = 101;\n// var arr = [];\n// arr.splice(0);\n// var string = \"\";\n// if (check(input) == \"is prim\") {\n// string = \"1\" + \"*\" + input ;\n// }\n// if (check(input) == \"not prim\") {\n// decompose(input);\n// }\n// function check(num) {\n// for (var i = 2; i \u003c Math.sqrt(num); i++) {\n// if (num % i === 0) {\n// return \"not prim\";\n// }\n// }\n// return \"is prim\";\n// }\n// function decompose(num) {\n// while (input \u003e 1) {\n// for (var k = 2; k \u003c= input; k++) {\n// if (input % k === 0) {\n// input = input / k;\n// arr.push(k);\n// break;\n// }\n// }\n// }\n// for (var i = 0; i \u003c arr.length; i++) {\n// if (i != arr.length - 1)\n// string = string + arr[i] + \"*\";\n// else\n// string = string + arr[i];\n// }\n// }\n// console.log(string);\n// --------------------------------------------------------------------------\n// console.log(fib(5));\n// function fib(num) {\n// if (num === 0)\n// return 0;\n// if (num === 1)\n// return 1;\n// if (num \u003e 1)\n// return fib(num - 1)+ fib(num - 2);\n// }\nvar arr = [0,1];\ndp_fib(4);\nfunction dp_fib(num) {\n for (var i = 2; i \u003c= num; i++){\n arr[i] = arr[i - 1] + arr[i - 2];\n }\n console.log(arr[num]);\n}","created_at":"2020-03-08T15:19:20.369+08:00","updated_at":"2020-04-26T14:50:15.823+08:00","name":"homework","language":"javascript","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/131529/fd1ac05835b665cf0d7e3c5532c7c2d7.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":48,"hashid":"p93s63ez","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦