[問題] c++
為什麼每次跑出來的結果都相同
都是100,0
有人可以告訴我是什麼地方錯了嗎
感激不盡
p.s 還沒100%完成
#include <iostream>
#include <ctime>
#include <cstdlib>
using std::cout;
using std::endl;
int flip( void );
int main()
{
int head = 0;
int tail = 0;
for(int i=1; i<=100; i++){
int result = flip();
if( result = 0 )
tail = tail + 1;
else
head = head + 1;
}
cout<<head<<endl;
cout<<tail<<endl;
return 0;
}
int flip( void )
{
int value;
srand( time( 0 ) );
value = rand() % 2;
return value;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.230.4.94
討論串 (同標題文章)