시간복잡도 구하려고 time++꽊꽊 채웠는데 printf하면 계속 0으로 뜬다...  왜그러져??!!


#include <stdio.h>

#include<stdlib.h>

#include<time.h>


#define MAX_SIZE 10000


void heapsort(int a[], int array_size, int *time);

void adjust(int a[], int root, int n, int time);

void display(int a[], int array_size);



int main(void)

{

int i, n, m;

int *th; // 시간복잡도를 위한 변수

srand((unsigned)time(NULL));

n= rand()0;

int a[n];

int b[n], c[n], d[n];

printf("Original Numbers:\n");

for(i=0; i < n; i++)

{

a[i] = rand()00;

printf("%d ", a[i]);

}


heapsort(a, n-1, &th);

 display(a, n);


return 0;

}



void heapsort(int a[], int n, int *time)

{

int i, temp;

for (i = n/2 - 1; i >= 0; i--)

adjust(a, i, n, *time);


for (i = n; i >= 1; i--) {

temp = a[0]; *time++;

a[0] = a[i]; *time++;

a[i] = temp; *time++;


adjust(a, 0, i-1, *time);

}

}



void adjust(int a[], int root, int n, int time)

{

int child, temp;


while ((2 * root + 1) <= n) {

child = 2 * root + 1; time++;         


if (child < n && a[child] < a[child + 1]) 

child++; time++;              


if (a[root] > a[child]) 

break;

else {

temp = a[root]; time++;

a[root] = a[child]; time++;

a[child] = temp; time++;


root = child; time++;

}

}

}