다시 부탁좀 드릴게요 ㅜ
올리브
#include stdio.h
#include math.h
#define MAX_SIZE 101
#define SWAP(x,y,t) ((t) = (x), (x)=(y), (y)=(t))
void sort(int [],int);
void main(void)
{
int i,n;
int list[MAX_SIZE];
printf(Enter the number of numbers to generate: );
scanf(%d,&n);
if(n1||nMAX_SIZE){
fprintf(stderr, Improper value of n\n);
exit(EXIT_FAILURE);
}
for(i=0; in; i++){
list[i] = rand() % 1000;
printf(%d ,list[i]);
}
sort(list,n);
printf(\n Sorted array:\n );
for(i=0; in; i++)
printf(%d ,list[i]);
printf(\n);
}
void sort(int list[], int n)
{
int i, j, min, temp;
for(i=0; in-1; i++)
{
min = i;
for(j=i+1; jn; j++)
if(list[j] list[min])
min =j;
SWAP(list[i],list[min],temp);
}
}이걸 selectionSort.h 로 저장햇구요 #include stdio.h
#include time.h
#include selectionSort.h
#define MAX_SIZE 10001
void main(void)
{
int i, n, step = 100;
int a[MAX_SIZE];
double duration;printf( n repetitions time\n);
for (n=0 ; n=10000 ; n+=step)
{
long repetitions = 0;
clock_t start = clock();
do
{
repetitons++;
for(i=0 ; in ; i++)
a[i] = n-i;
sort(a, n);
}while (clock() - start 10000); duration = ((double) (clock() - start))
/ CLOCKS_PER_SEC;
duration /= repetitions;
printf(%6d %9d %f\n, n, repetitions, duration);
if (n == 1000) step = 1000;
}
}
이걸 해봣는데 에러가 더 많이...ㄷㄷ;; 헤더를 만드는방식이 잘못됫나요??;;이거 책보고 하는데도 안되니깐 진짜 미칠것같네요 ㅜㅜ