Comparing the well-known sorting algorithm
ไหนๆ เรียนวิชา Algorithm มาแล้ว มาเขียน Blog ให้เป็นประโยชน์กะรุ่นน้องหน่อยละกัน Bubble Sort [O(n²)] 1 2 3 4 5 6 7 8 9 def bubble(list): swap = True while swap: swap = False for i in range(len(list)-1): if list[i] > list[i+1] : list[i],list[i+1] = list[i+1],list[i] swap = True return list รา ...
Read More[Ubuntu] Mono C# installation with terminal
ตะกี๊ @pamon ไม่สามารถ run C# บน Ubuntu ไปดูวิธี Setup Environment กันหน่อยดีกว่า คุ้นๆกันดีว่า มี โมโน(Mono) บนระบบ Unix ที่สามารถ Run .Net Framework ได้ Cross-Platform ทั้ง Unix, Windows และ Mac ซึ่งปัจจุบันออกไปถึง Version 2.4 ซะแล้ว(ณ วันที่ 18 June 2009) วิธ ...
Read MoreMethod Swap – without temporary variable
ตัวอย่างข้างต้น เป็นการเขียนโปรแกรม swap ค่าแบบแปลกๆครับ ไม่ต้องมาสร้างตัวแปร temp อีกแย๊ว จะนำเสนอ 2 วิธีครับ วิธีแรก :: การใช้ Operator XOR ตัวอย่าง code สำหรับ ภาษา C# 1 2 3 4 5 void swap (ref int a, ref int b) { a ^= b; b ^= a; a ^= b; & ...
Read MoreBasic way to solve the problems.
Make it work. Make it right. Then make it fast. หมายความว่ายังไง Make it work. เีขียนโปรแกรมให้มันทำงานได้ซะก่อน Make it right. เขียนโปรแกรมให้มันแสดงผลได้ถูกต้อง Then make it fast. เขียนโปรแกรมให้มันทำงานได้เร็วที่สุดและ optimize ที่สุด ซึ ...
Read More