精華區beta Tech_Job 關於我們 聯絡資訊
不知道可不可以這樣解... int children[2]; // 1 is boy and 0 is girl // children[0] is elder, children[1] is younger int firstseeisboycount = 0; int secondseeisboycount = 0; randomize(); for(int i=0;i<10000;i++){ children[0]=rand()%2; children[1]=rand()%2; int firstseeindex = rand()%2; // firstsee is elder or younger if(children[firstseeindex]==1){ // 1st see is boy firstseeisboycount++; if(firstseeindex==0){ if(children[1]==1){ secondseeisboycount++; } } else{ if(children[0]==1){ secondseeisboycount++; } } } } 所以機率就是 secondseeisboycount/firstseeisboycount ~= 1/2 這樣對嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.249.75.114
henryfy:帥氣喔 程式都出來了~~~~ 01/13 13:53
ray110411:學類比ic的 懶得看~ 01/13 13:53
delete0623:cool~ 01/13 13:53
carlcarl:現在重點變成對題意理解不同 所以用程式跑可能沒意義.. 01/13 13:56
erotic:把問題複雜化,先fire再說 = = 01/13 14:24