다시;

뒹굴남 작성일 12.08.10 03:19:22
댓글 18조회 3,869추천 4

 미안

소스에 버그가 있었어;

134453629192849.jpg


아래는 소스

- (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]];

    }

}




논란 끝

바꾸는게 훨 나음

 
뒹굴남의 최근 게시물

엽기유머 인기 게시글