發表文章

Solutions to Blocky Game Maze (Blockly 迷宮遊戲參考解法)

圖片
If you like this post, please click the ads on the blog or  buy me a coffee . Thank you very much. Level 1: Level 2: Level 3: Level 4: Level 5: Level 6: Solution 1: Solution 2: Level 7: Level 8: Solution 1: Solution 2: Level 9: Level 10: Solution 1: Solution 2: 若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。 If you like this post, please click the ads on the blog or  buy me a coffee . Thank you very much.

當一小時玩程式:「冰雪奇緣」遇到 Python Turtle Block

圖片
此篇文章說明筆者示範用【一小時玩程式:「冰雪奇緣」】與 Python Turtle 來學習 Python。 請先看一小時玩程式「冰雪奇緣」介紹影片,了解冰雪奇緣如何進行: 和安娜與艾莎一同玩程式 https://studio.code.org/s/frozen/stage/1/puzzle/1 Python Turtle 線上版本 https://trinket.io/turtle Python Turtle Block線上版本 https://trinket.io/blocks 第一關畫直線 https://studio.code.org/s/frozen/stage/1/puzzle/1 HOC Block Code: Python Block Code: HOC 與 Python 的積木有沒有很像呢? Javascript 語法: moveForward(100); Python 語法: import turtle turtle.forward(100) Javascript 與 Python 的語法有沒有很像呢? Python Turtle 結果: 從以上可以看出 Javascript 與 Python 語法有類似的地方。 筆者建議讀者可使用  https://trinket.io/turtle  來練習 Python 的語法,而當語法想不起來時, https://trinket.io/blocks  是可以用來輔助熟悉語法的。 第二關畫L型 HOC Block Code: Python Block Code: 第三、四關畫正方形 HOC Block Code: Python Block Code: 第五關畫三個正方形 HOC Block Code: Python Block Code: 第六關畫十個正方形 HOC Block Code: Python Block Code: 第七關畫十字 HOC Block Code: Python Block Code: 第八關畫五條交叉線 HOC Block Co...

資訊安全:惡作劇程式

圖片
此篇文章將使用C++程式寫些惱人的程式。測試環境為 Virtualbox 虛擬機 上的 Windows XP Pro版本,C++ IDE為 Code::Blocks 。 貪吃鬼(灌爆硬碟、吃光記憶體) 吃光記憶體C程式碼: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include <stdio.h> #include <stdlib.h> int main () { char * data; // the data long long int N = ( 1024 * 1024 * 1024 ); // Memory size data = ( char * ) malloc(N); // Generate Random value for ( int i =0 ;i < N;i ++ ){ data[i] = ( char ) rand(); } return 0 ; } 結果:還沒吃記憶體前,XP作業系統會刪掉此程式(當記憶體使用率 Mem Usage快暴時,下圖中的Hi.exe會突然不見)。 灌爆硬碟C程式碼: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include <stdio.h> #include <stdlib.h> int main () { char * data; // data to be written int N = ( 1024*1024 ); // 10M for each flush data = ( char * ) malloc(N); // Generate Random value for ( int i =0 ;i < N;i ++ ){ data[i] = ( char ) rand(); } // T...