Lỗi Radix Sort
Radix Sort
Code:
#include  <stdio.h>
#include  <conio.h>
#include  <stdlib.h>
#include  <time.h>
void  RadixSort  ( int a, int n );
int  CountDigit  ( int n );
void  Output  ( int a, int n );
int  GetMax  ( int A, int n );
void  Swap  ( int a, int b );
void  Random  ( int a, int n );
int  GetDigit  ( int n, int t );
void  Send2Box  ( int A, int n, int b[10], int num[10], int t );
void  GetValue  ( int A, int b[10], int nn[10] );

void main( )  {
	int *a, n;
	printf( "Nhap vao so phan tu cua mang: \n" );  
	scanf ("%d", &n );  
	a = new int[n];  Random( a, n );  
	Output( a, n );  RadixSort( a, n );
	printf( "Mang sau khi sap xep \n" );  
	Output( a, n );  
	getch( );    
}
void  RadixSort  ( int a, int n )  {
	int i;  int Box[10];  int number[10];  
	for ( i = 0; i < 10;  i++ )  {
		Box[i] = new int [n];  
		if ( Box[i] == NULL) 	{
			printf("Not enough" );  return;	}
			number[i] = 0;					
	}
	int nn = CountDigit (GetMax( a, n) );
	for ( i = 0; i < nn;  i++ )  {
		Send2Box( a, n, Box, number, i );  
		GetValue( a, Box, number );
	}  
}
int GetMax ( int A, int n)   {//tim phan tu lon nhat
	int max = A[0];  
		for( int i = 1; i < n;  i++ )  
			if ( max < A[i])  
				max = A[i];  
	return max;
}
int CountDigit ( int n ) 	{ // dem so chu so cua 1 phan tu
	int count = 0;  
	while(n > 0 )  {
		count++;  n = n/10; }
    return count;			
}
int GetDigit ( int n, int t )  { // lay gia tri tung hang
	int value = 1;  
	for ( int i = 0;  i < t;  i++ )  
		value = value * 10;
	return ( (n/value)%10 );  
		}
void Send2Box ( int A, int n, int b[10], int num[10], int t )  { // dua vao hop
	for ( int i = 0;  i < n;  i++ )  {
		int tt = GetDigit( a[i], t );
		b[tt][num[tt]++] = A[i];	}
		}
void GetValue( int A, int b[10], int nn[10] )  { // lay gia tri ra
	int j = 0;  
	for( int i = 0; i < 10;   i++ )  {
		if ( nn[i] != 0 )  {
			for ( int k = 0; k < nn[i]; k++)
				A[j++] = b[i][k];  nn[i] = 0;
								}			}  
}
void Output ( int a, int n )  {
	int i;  
	for ( i = 0; i < n;   i++ )  {
		printf( "t[%d] = %d  \n", i, a[i] ); }
}
void Swap ( int a, int b )  {  
    int temp = a;  a = b;  b = temp;  
}  
void Random ( int a, int n )  {  
	int k;  
	printf("mang co %d phan tu  \n", n );  
	srand (time( 0 ) );  
	printf( "Entering random values from 0 to 500 into array  \n" );  
	for ( k = 0; k <= n; k ++)  
		a[k] = rand() % 500 +1;
}
Code của mình bị lỗi gì vậy?