目前分類:C/C++討論 (8)

瀏覽方式: 標題列表 簡短摘要
其實這個議題對於每次遇到要寫類似迷宮程式的時候都是一個頭痛需要思考的問題。
在此我就提供其中一個方法,也許方法很多我的不代表就是最佳但是一個參考方向。

當你要寫迷宮程式的時候也許你會有以下的作法:
1.亂數隨意產生牆壁的作法,長度不要過長的方式來達到,但有會走不到終點的情況,因為有死路產生。
2.乾脆將地圖寫死,多做幾個在程式中亂數選擇之一,還算可以的作法好處是不會有死路產生但變化不多。
3.取一的作法加入更多的限制條件,但是還是會有死路產生的狀況無法解決。
條件:在下點的情況下需檢查周圍狀況之類.....
我這提供的作法其實很簡單,就是把路先長出來然後填牆......說來簡單就幾句話而已,難道我當大家是白癡喔!!
大家都知道阿....問題就在作法上的處理了。
我以31x31的地圖大小來做說明,記住地圖一定要是積數絕不要用偶數,如果使用我的方法的話。
範例使用C語言設計,請不要問我其他語言請自行修改設計。

NBPBlog 發表在 痞客邦 留言(0) 人氣()

C++ multi-thread簡易範例

NBPBlog 發表在 痞客邦 留言(0) 人氣()

利用sort algorithm寫一個排序範例.....


NBPBlog 發表在 痞客邦 留言(0) 人氣()

You would think on the face of it, that STL - with all of its abstraction and templates - would be slower than doing things the "old fashioned way". However my tests do not bear that out. For a simple test, I wrote a small program that generated 10,000,000 (10 million) random numbers and sorted them using the inbuilt STL sort. Here it is ...

NBPBlog 發表在 痞客邦 留言(0) 人氣()

 

找程式碼請入內~~

NBPBlog 發表在 痞客邦 留言(3) 人氣()

assdkijj 詢問~~

使用高斯消去法要如寫出阿

NBPBlog 發表在 痞客邦 留言(0) 人氣()

利用sort algorithm寫一個排序範例.....

NBPBlog 發表在 痞客邦 留言(0) 人氣()

Does Windows have a limit of 2000 threads per process?

Often I see people asking why they can't create more than around 2000 threads in a process. The reason is not that there is any particular limit inherent in Windows. Rather, the programmer failed to take into account the amount of address space each thread uses.

A thread consists of some memory in kernel mode (kernel stacks and object management), some memory in user mode (the thread environment block, thread-local storage, that sort of thing), plus its stack. (Or stacks if you're on an Itanium system.)

NBPBlog 發表在 痞客邦 留言(0) 人氣()