C언어로 버블,선택,퀵소팅 구현
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

C언어로 버블,선택,퀵소팅 구현에 대한 보고서 자료입니다.

목차

1. Bubble Sorting

2. Selection Sorting

3. Qick Sorting

본문내용

) srand((unsigned)time(NULL)) //난수 초기화 매크로
#define N 1000
void swap(int a[], int from, int to) // swap 하는 함수
{
int temp;
temp = a[from];
a[from] = a[to];
a[to] = temp;
}
main()
{
int i,j,min,loop;
int a[N];
randomize();
for(i=0;i a[i] = rand()%1000 + 1;
printf("\n\n----------------정렬 전----------------\n\n");
for(i=0;i {
printf("[ %d ]", a[i]);
}
// 선택 정렬하는 부분
for(i=0;i {
min=i;
for(j=i+1;j if(a[j] < a[min])
{
min = j;
}
swap(a,min,i);
}
printf("\n\n----------------정렬 후----------------\n\n");
for(i=0;i {
printf("[ %d ]", a[i]); } }
2_2 출력
3. Qick Sorting
3_1 코드
#include
#include
#include
#define N 1000
#define randomize() srand((unsigned)time(NULL)) //난수 초기화 매크로
void qick_sort(int num[], int low, int high)
{
int i,j;
int pivot;
int temp;
i=low, j=high +1;
pivot = num[low];
if(low < high)
{
do
{
do
{
i++;
}while(num[i] < pivot);
do
{
j--;
}while(num[j] > pivot);
if(i {
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}while(i num[low] = num[j];
num[j] = pivot;
qick_sort(num, low, j-1);
qick_sort(num, j+1, high);
}
}
main()
{
int i,j,loop;
int a[N];
randomize();
for(i=0;i a[i] = rand()%1000 + 1;
printf("\n\n----------------정렬 전----------------\n\n");
for(i=0;i<1000;i++)
{
printf("[ %d ]", a[i]);
}
// 퀵 소팅하는 부분
for(i=0;i {
for(j=0;j if(a[i] < a[j])
{
qick_sort(a,j,i);
}
}
printf("\n\n----------------정렬 후----------------\n\n");
for(i=0;i<1000;i++)
{
printf("[ %d ]", a[i]);
}
}
3_2 출력

키워드

버블,   선택,   ,   소팅,   C언어,   자료구조
  • 가격1,000
  • 페이지수7페이지
  • 등록일2006.06.13
  • 저작시기2006.4
  • 파일형식한글(hwp)
  • 자료번호#354711
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니