[問題] 如何寫一個亂數產生器,數字不能重覆
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
如何寫一個亂數產生器,數字不重覆?
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int c,a;
srand(time(NULL));
printf("The ans is :\n");
for(a=1;a<=100;a++)
{
// srand(time(NULL));
c=rand()%100+1;
printf(" %d\t",c);
}
system("pause");
return 0;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.39.0.75
推
10/07 09:55, , 1F
10/07 09:55, 1F
→
10/07 09:57, , 2F
10/07 09:57, 2F
→
10/07 10:49, , 3F
10/07 10:49, 3F
推
10/07 11:31, , 4F
10/07 11:31, 4F
推
10/08 12:33, , 5F
10/08 12:33, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章