게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
C코드 질문좀 드립니다.
게시물ID : programmer_8936짧은주소 복사하기
작성자 : 푸웅
추천 : 0
조회수 : 291회
댓글수 : 2개
등록시간 : 2015/03/27 14:07:34

#ifndef ABS #define ABS( x ) (( ( x ) >= 0 )? (x) : -(x)) #endif

for (length = 1; length < 15; length++)

{

temp = Sorting_Buf[length];

for (compare = length -1; compare >= 0 && Sorting_Buf[compare] > temp; compare--)

{

Sorting_Buf[compare +1] = Sorting_Buf[compare];

}

Sorting_Buf[compare + 1] = temp;

}

삽입정렬인데요..

동작잘됩니다.. Sorting이 잘되요~~ 근데 Sorting 되는것을 정수가아니라 절대값으로 Sorting 할려고~ 

이코드에서 


for (length = 1; length < 15; length++)

{

temp = Sorting_Buf[length];

for (compare = length -1; compare >= 0 && ABS(Sorting_Buf[compare]) > ABS(temp); compare--)

{

Sorting_Buf[compare +1] = Sorting_Buf[compare];

}

Sorting_Buf[compare + 1] = temp;

}


이렇게 바꾸면 MCU가 죽습니다. 하하하하하하하 뭐지~!?

꼬릿말 보기
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호