この問題おかしい2

このエントリーをはてなブックマークに追加
<HTML><HEAD><TITLE>4900回とかやってみましょう</TITLE></HEAD><BODY><SCRIPT language="JavaScript">
<!--
function draw(cards) {
do { c = Math.floor((13*4)* Math.random());
if (cards[c]!=null) {drawed = cards[c];cards[c] = null;return drawed;}
} while (true);
}
function ransuu(form1) {
form1.disp.value=""; TimesDiaInBox=0;TimesSpadeInBox=0;TimesHeartInBox=0;TimesCrubInBox=0;
for (n=0; n<form1.kaisu.value; ++n) {
cards = new Array( "S1","S2","S3","S4","S5","S6","S7","S8","S9","S10","S11","S12","S13",
"H1","H2","H3","H4","H5","H6","H7","H8","H9","H10","H11","H12","H13",
"C1","C2","C3","C4","C5","C6","C7","C8","C9","C10","C11","C12","C13",
"D1","D2","D3","D4","D5","D6","D7","D8","D9","D10","D11","D12","D13");
inBoxCard = draw(cards);//One card was into a box.

//Three cards ware all dias.
notTheCase = false;
for (m=0; m<3; m++) {
opened = draw(cards); if (opened.charAt(0)!='D') {notTheCase = true; break; }
}if (notTheCase==true){ --n; continue;}

//Is the card was dia?
inBoxCardSuit=inBoxCard.charAt(0);
if(inBoxCardSuit=='D'){TimesDiaInBox++;}else if(inBoxCardSuit=='S'){TimesSpadeInBox++;}
else if(inBoxCardSuit=='H'){TimesHeartInBox++;}else{TimesCrubInBox++;}
form1.disp.value = "S:"+TimesSpadeInBox+" H:"+TimesHeartInBox+" C:"+TimesCrubInBox+" D:"+TimesDiaInBox+" / " + (n+1);
}
}
//-->
</SCRIPT><P>実験</P><FORM><INPUT size="10" type="text" name="kaisu"> 回<INPUT type="button" value="go" onclick="ransuu(this.form);"><BR>
<TEXTAREA rows="2" cols="40" name="disp"></TEXTAREA></FORM></BODY></HTML>