2012년 10월 1일 월요일

버블소트 C 소스 to 훈민상미

#include

void BubbleSort(int DataSet[], int nLength)
{
int nI = 0;
int nJ = 0;
int nTemp = 0;

for(nI = 0; nI < nLength - 1; ++nI)
{
for(nJ = 0; nJ < nLength - (i + 1); ++nJ)
{
if( DataSet[nJ] > DataSet[nJ + 1] )
{
nTemp = DataSet[nJ+1];
DataSet[nJ+1] = DataSet[nJ];
DataSet[nJ] = nTemp;
}
}
}
}

int main(int argc, char *argv[])
{
int nDataSet[] = {6, 4, 2, 3, 1, 10};
int nLength = sizeof(nDataSet)/sizeof(nDataSet[0]);
int nI = 0;

BubbleSort(nDataSet, nLength);

for(nI = 0; nI < nLength; ++nI)
{
printf("%d\n", nDataSet[nI]);
}

return 0;
}


인터넷 뒤져보니 있네.

i가 없는 걸로 봐서 이전에 포스팅한 소스를 토대로 버블 소트 한번 만들어봐~


댓글 없음:

댓글 쓰기

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...