{"id":9023,"student_id":1470,"content":"setBackdrop(\"gold\");\nvar len = 10;\nvar randomArr = [];\nvar isFinished = false;\nfunction initArr(len){\n for(var i = 0; i \u003c len; i++){\n randomArr[i] = Math.random();\n }\n}\n\nfunction bubbleSort(randomArr) {\n\n var swaps = 0;\n \n for (var i = 1; i \u003c randomArr.length; i++) {\n \n if (randomArr[i] \u003c randomArr[i - 1]) {\n \n swap(randomArr, i, i - 1);\n swaps++;\n }\n }\n\n if(swaps \u003e 0){\n return false;\n \n } else {\n return true;\n }\n\n return randomArr;\n\n}\n\n\nfunction selectionSort(randomArr, i) {\n var min = randomArr[i];\n var index = i;\n for(var j = i; j \u003c randomArr.length; j++){\n if(min \u003e randomArr[j]){\n min = randomArr[j];\n index = j;\n }\n }\n swap(randomArr, i, index);\n if(i \u003e= randomArr.length - 1){\n return true;\n } else {\n return false;\n \n } \n\n}\ninitArr(10);\nvar i = 0;\nvar interval = setInterval(function(){\n \n if( bubbleSort(randomArr, i) ){\n setBackdrop(\"goldenrod\");\n isFinished = true;\n clearInterval(interval);\n \n } else {\n ++i;\n \n }\n \n},500);\n\n\nforever(function(){\n drawKoding(randomArr);\n if(isFinished){\n print(\"FINISHED\", 100, 100, \"white\", 100);\n }\n});\n\n\n// console.log(bubbleSort(randomArr));\n\n\n","created_at":"2017-03-01T20:52:04.729+08:00","updated_at":"2019-11-12T03:18:50.493+08:00","name":"排序QQ","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/9023/b3d13a3606f74fe353865d0e91de1262.jpg"},"parent_id":2,"plugin":"\n\nfunction swap(arr, i1, i2) {\n var b = arr[i1];\n arr[i1] = arr[i2];\n arr[i2] = b;\n randomArr = arr;\n var counter = 1;\n drawKoding(arr);\n \n}\n\nvar kodings = [];\nfunction normaliseKoding(arr) {\n var max = 0,\n normArr = [];\n //console.log(arr);\n for (var i = 0; i \u003c arr.length; i++) {\n if (max \u003c= arr[i]) {\n max = arr[i];\n }\n }\n for (var i = 0; i \u003c arr.length; i++) {\n normArr[i] = arr[i] / max;\n }\n return normArr;\n}\n\nfunction drawKoding(arr) {\n //console.log(\"DrawArr : \" + arr);\n var norm = normaliseKoding(arr);\n for (var i = 0; i \u003c kodings.length; i++) {\n kodings[i].destroy();\n }\n var parts = 640/(arr.length+1);\n \n for(var i = 0; i \u003c norm.length; i++){\n //console.log(norm[i]);\n \n pen.fillColor = \"hsl(0, 100%,\" + (norm[i]*100) + \"%)\";\n pen.drawRect(20 + parts*i - 10, 30, parts - 10, norm[i]*100);\n }\n\n}\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":459,"hashid":"npmsmqv","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":198137,"file_name":"0.png","project_id":9023,"asset_id":6,"created_at":"2017-08-09T14:58:13.260+08:00","updated_at":"2017-08-09T14:58:13.260+08:00"},{"id":198138,"file_name":"1.svg","project_id":9023,"asset_id":7,"created_at":"2017-08-09T14:58:13.264+08:00","updated_at":"2017-08-09T14:58:13.264+08:00"},{"id":198139,"file_name":"2.png","project_id":9023,"asset_id":8,"created_at":"2017-08-09T14:58:13.278+08:00","updated_at":"2017-08-09T14:58:13.278+08:00"},{"id":198140,"file_name":"0.wav","project_id":9023,"asset_id":9,"created_at":"2017-08-09T14:58:13.281+08:00","updated_at":"2017-08-09T14:58:13.281+08:00"},{"id":198141,"file_name":"1.wav","project_id":9023,"asset_id":10,"created_at":"2017-08-09T14:58:13.284+08:00","updated_at":"2017-08-09T14:58:13.284+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦