|
|
|
 |
b[0]. col=a[0]. row;
row-terms[a[i]. col] ++;//Arow-terms1
j=starting-pos[a[i]. col] ++;
b [j]. row=a[i]. col;
b [j]. col=a[i]. row;
printf("a[%d] |%d||", i, arr[i]);
printf("row-terms[%d]|%d||", i, cou nt[i]) ;//
a[i]= B[i+1].value;
|
|
|
 |
Fastt ranspos e의 row-terms 배열에 a의 항목들의 개수를 채워넣고, 이를 이용하여 starting-pos 배열을 계산한다.
c 이와 같은 방식으로 계속 진행하면 a배열의 항목들이 sorted 배열에 정렬되게 된다.
위와 같은 정렬 방식을 Cou ntingSort 라 한다
introw-terms[MAX];
b[0]. row=num-col;
b[0].value=num-terms;
for(i=0; i
printf("row-terms[%d]= % d\n", i, row-terms[i]);
starting-pos[i]=starting-pos [i-1]+row-terms[i-1];
printf("starting-pos[%d]= % d\n", i, starting-pos [i]);
j=starting-pos[a[i]. col] ++;
printf("j=% 2d=starting-pos[a[%2d]. col] ++=starting-pos[%d]++\n", j, i, a[i]. col);
b [j]. row=a[i]. col;
printf("a[%d] |%d||", i, arr[i]);
intval=ar r[i];
printf("row-terms[%d]|%d||", i, cou nt[i]) ;//
printf("%d|", i);
A[0]. col=101;A[0]. row=101;A[0].value=100;
A[i]. col=i; A[i]. row=i; A[i].value=(rand()% 100);
a[i]= B[i+1].value; |
 |
i, a, d, row, col, terms, b, pos, starting, 정렬, n, printf, 배열, cou, j, value, h, time, 100, e |
|
|
|
|
|
 |
|
|
|
|
|
|
|
|
|
|
|
|