미안
소스에 버그가 있었어;
아래는 소스
- (void) startThread
{
srand(time(NULL));
int cnt1 = 0;
// change
for(int i=0; i<num; i++)
{
// 정답 위치.
int val = rand()%3;
// 선택 위치
int chooseVal = rand()%3;
// 여는 위치.
int openVal = rand()%3;
while( chooseVal == openVal || val == openVal )
{
openVal = rand()%3;
}
//위치 바꾸기.
int newChooseVal = rand()%3;
while( newChooseVal == chooseVal || newChooseVal == openVal )
{
newChooseVal = rand()%3;
}
if( newChooseVal == val)
{
cnt1++;
}
UILabel * lab = (UILabel *)[self.view viewWithTag:3];
[lab setText:[NSString stringWithFormat:@"%.4f", (CGFloat)cnt1 / (CGFloat)num]];
}
int cnt2 = 0;
// not change
for(int i=0; i<num; i++)
{
// 정답 위치.
int val = rand()%3;
// 선택 위치
int chooseVal = rand()%3;
// 여는 위치.
int openVal = rand()%3;
while( chooseVal == openVal || val == openVal )
{
openVal = rand()%3;
}
if( chooseVal == val)
{
cnt2++;
}
UILabel * lab = (UILabel *)[self.view viewWithTag:2];
[lab setText:[NSString stringWithFormat:@"%.4f", (CGFloat)cnt2 / (CGFloat)num]];
}
}
논란 끝
바꾸는게 훨 나음