• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 關於程式指令
#6
新會員
新會員


查看用戶資訊
那以c語言來說,該怎麼取得這樣的一個亂數值呢?

發表於: 2009/12/31 15:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於程式指令
#5
版主
版主


查看用戶資訊
第一次的亂數可以考慮用開機後的初始 RAM 的值在未被初始化前的值,把它加總一下應可得到一個初始亂數值。
因為 RAM 開機時其值是亂的,經 C 的啟動設定後才會有固定的初始值。

發表於: 2009/9/16 17:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於程式指令
#4
新會員
新會員


查看用戶資訊
感謝提供rand()指令 但還有一個問題 就是rand()產生亂數
每次程式從新執行後亂數產生順序都依樣 是否有解決方式
謝謝

發表於: 2009/9/16 15:15
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於程式指令
#3
版主
版主


查看用戶資訊
在 C30 裡的使用手冊裡有:
C:\Program Files\Microchip\MPLAB C30\docs\16-Bit_Language_Tools_Getting_Started_70094E.pdf

rand
Description
Generates a pseudo-random integer.
Include: <
stdlib.h>
Prototypeint rand(void);
Return 
ValueReturns an integer between 0 and RAND_MAX.
RemarksCalls to this function return pseudo-random integer values in the range
[0,RAND_MAX]. To use this function effectivelyyou must seed the random
number generator using the srand 
function. This function will
always 
return the same sequence of integers when no seeds are used
(as in the example below) or when identical seed values are used. (See
srand 
for seed example.)
Example#include <stdio.h> /* for printf */
#include <stdlib.h> /* for rand */
int main(void)
{
int x;
for (
05x++)
printf("Number = %dn"rand());
}
Output:
Number 21422
Number 
2061
Number 
16443
Number 
11617
Number 
9125
Notice 
if the program is run a second timethe numbers are the same.
See the example for srand to seed the random number generator.

發表於: 2009/9/16 11:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於程式指令
#2
中級會員
中級會員


查看用戶資訊
之前有看到
利用空的AD腳位浮 抓取數筆資料
再混合一下的方式來達到亂數的效果

可能不是很正統,不過還蠻有趣的方式

發表於: 2009/9/16 0:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於程式指令
#1
新會員
新會員


查看用戶資訊
各位大大 最近在寫一些最佳化程式 需時用到亂數
想情問一下dsPIC30F4011 是否有提供亂數產生的指令
使用C語言 謝謝

發表於: 2009/9/15 18:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------