[問題] c++

看板NTUEE107HW作者 (丹尼爾˙柯)時間22年前 (2003/11/03 01:25), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/7 (看更多)
為什麼每次跑出來的結果都相同 都是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
文章代碼(AID): #_fJuBxe (NTUEE107HW)
討論串 (同標題文章)
完整討論串 (本文為第 1 之 7 篇):
問題
3
3
問題
問題
1
1
問題
問題
問題
問題
文章代碼(AID): #_fJuBxe (NTUEE107HW)