|
디버그 모드로 컴파일 하셨으면 에러난 라인이 포커싱 될텐데요.
기본적으로 점검해야 할 것은 도대체 무슨 리스트냐는건데,
divn_count 등의 낯선 함수가 있는것으로 봐서는 직접 구현한 리스트인듯 싶습니다만...
리스트의 마지막 멤버의 next가 항상 NULL을 가지게 구현해 두신건지 점검해 보셔야 할 듯 하고...
이 경우, arr_divn 배열의 태그(인덱스)가 잘못 되었든지, list->next에 쓰레기 값이 들어있든지..
두가지 경우 밖에 문제를 생각할 수 없습니다.
에러가 발생할 위치도 몇 군데 안되고 별것 아니니 차분히 들여다 보세요.
풍차나라 님이 쓰신 글 :
: 아래는 ...
: 리스트에 저장되어 있는 자료들에게 랜덤으로 의사결정 번호를 부여하는 코드 입니다.
: 랜덤은 그냥 발생시키는게 아니라 ... 리스트의 전체 개수에 맞게 배열을 만든다음 ...
: 그 배열의 순서를 마구 뒤섞었습니다.
:
: 그 다음 ... 배열을 리스트 while 문 안에서 하나하나 꺼내어서 ...
: 그 배열값에 따라 리스트 각각에 의사결정 번호를 부여하였습니다.
:
: 컴파일은 되는데 ... 프로그램에서 실행버튼을 클릭하니깐 ...
: Access Violation 이 발생하네요.
:
: 도대체 왜 안되는지 ... 엄청난 시간동안 좌절 중 ... ㅜㅜ;;;
: 답변 부탁 드립니다.
:
:
: //---------------------------------------------------------------------------------------------
: list = head;
: if (list == NULL) return false;
:
: randomize();
: int init_total = list->divn_count();
: int minus_total = init_total;
: int *arr_divn = (int *)malloc(sizeof(int)*init_total);// divn_cnt); //new int arr_divn[sivn_cnt*sizeof(int)];
:
: for(int i=0 ; i<init_total ; i++) {
: arr_divn[i] = i+1; //배열에 값을 부여
: }
: int cnt = init_total;
: for(int j=0 ; j<init_total ; j++) {
: int first_id = int(random(init_total) % cnt);
: int second_id = --cnt;
:
: int first = arr_divn[first_id]; //두개의 배열을 랜덤으로 선정
: int second = arr_divn[second_id];
:
: arr_divn[first_id] = second; //두개의 값을 바꿈
: arr_divn[second_id] = first;
: }
: int sect=0;
: while(list)
: {
: //int count = int(list->divn_count());
: //int tmp_id = int(list->rand_num.search(list->id));
: //int sect = probability(count, tmp_id);
:
: //////////////////////////////////////
: //Case 1.03 : 확률 자체 구현
: //초기 입력수를 기준으로 90-9-1% 구분
:
: sect = int((arr_divn[minus_total-1] / init_total) * 100);
: minus_total--;
:
: //--------------------------------------------------------------------//
:
: if (sect >= 10) list->decision = DIV_EVENT_1;
: else if (sect > 0 && sect < 10) list->decision = DIV_EVENT_2;
: else list->decision = DIV_EVENT_3;
:
: if (sect >=10) list->decision |= DIV_EVENT_4;
: else if (sect > 0 && sect < 10) list->decision |= DIV_EVENT_5;
: else list->decision |= DIV_EVENT_6;
:
: list = list->next;
: }
:
: free(arr_divn);
|