{"id":25981,"student_id":2591,"content":"var q = 4;\nvar chess = [[],[],[],[]];\nvar cx = 0;\nvar cy = 0;\nwhile (qc != q) {\n for (var x = 0; x \u003c q; x++) {\n for (var y = 0; y \u003c q; y++) {\n chess[x][y] = 0;\n }\n }\n var qc = 0;\n\n for (var x = cx; x \u003c q; x++) {\n for (var y = cy; y \u003c q; y++) {\n if (chess[x][y] == 0) {\n chess[x][y] = 1;\n qc++;\n console.log(\"queen\");\n for (var i = 0; i \u003c q; i++) {\n if (i != x \u0026\u0026 i != y) {\n chess[x][i] = 2;\n chess[i][y] = 2;\n if (x - i \u003e= 0 \u0026\u0026 y - i \u003e= 0) chess[x - i][y - i] = 2;\n if (x + i \u003c 4 \u0026\u0026 y - i \u003e= 0) chess[x + i][y - i] = 2;\n if (x - i \u003e= 0 \u0026\u0026 y + i \u003c 4) chess[x - i][y + i] = 2;\n if (x + i \u003c 4 \u0026\u0026 y + i \u003c 4) chess[x + i][y + i] = 2;\n }\n }\n }\n }\n }\n console.log(qc + \"failed\");\n cx++;\n if (cx \u003e= q) {\n cx = 0;\n cy++;\n }\n}\n\nfor(var i = 0 ; i \u003c 4; i++){\n for(var j = 0; j \u003c 4; j++){\n if((i + j) % 2 != 0){\n createSprite({\n x: i*120 + 140,\n y: j*120 + 60,\n scale: 2.0, // 2倍大\n costumes: [\"light.png\"]\n });\n }else{\n createSprite({\n x: i*120 + 140,\n y: j*120 + 60,\n scale: 2.0, // 2倍大\n costumes: [\"dark.png\"]\n });\n }\n if(chess[i][j] == 1){\n createSprite({\n x: i*120 + 140,\n y: j*120 + 60,\n scale: 2.0, // 2倍大\n costumes: [\"queen.png\"]\n });\n }\n } \n}","created_at":"2018-03-30T15:46:47.581+08:00","updated_at":"2019-09-23T21:38:55.608+08:00","name":"4皇后","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/25981/3f49d1a927ea85a20763d8c2190aeb0a.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":98,"hashid":"2pdsr8gp","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":481026,"file_name":"dark.png","project_id":25981,"asset_id":59491,"created_at":"2018-03-30T16:01:42.399+08:00","updated_at":"2018-03-30T16:01:42.399+08:00"},{"id":481027,"file_name":"light.png","project_id":25981,"asset_id":59492,"created_at":"2018-03-30T16:01:42.401+08:00","updated_at":"2018-03-30T16:01:42.401+08:00"},{"id":481028,"file_name":"queen.png","project_id":25981,"asset_id":59493,"created_at":"2018-03-30T16:01:47.936+08:00","updated_at":"2018-03-30T16:01:47.936+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦