¡Se necesita con urgencia el código fuente C de compresión de texto en inglés del algoritmo lzw!
#includelt;cstdiogt;
#includelt;cstringgt;
#includelt;ctimegt; //se utiliza para calcular el tiempo de compresión
usando namespace std;
/ Definir constantes
const int MAX = 1000003; //Número máximo de códigos, un número primo, el módulo es más rápido
const int ascii = 256; //número de códigos ascii
const int ByteSize = 8; //8 bytes
elemento de estructura//elementos en la tabla hash
{
clave int;
código int;
Elemento *siguiente
}*tabla[ MAX]; tabla
int hashfunction(int key)//función hash
{
return keyMAX;
}
void hashinit(void)//Inicialización de la tabla hash
{
memset(table, 0, sizeof(table));
} p>
void hashinsert(Elemento elemento)//Inserción de tabla hash
{
int k = hashfunction(element.key);
if (table[ k]! = NULL)
{
Elemento *e=table[k];
while(e-gt; next!=NULL ) p>
{
e=e-gt; siguiente;
}
e-gt; siguiente=nuevo elemento; p> p>
e=e-gt; siguiente;
e-gt; clave = elemento.clave;
e-gt; /p >
e-gt; siguiente = NULL
}
más
{
tabla[k]= nuevo elemento ;
tabla[k]-gt; clave = elemento.clave;
tabla[k]-gt; código = elemento.código;
table[ k]-gt.next = NULL;
}
}
bool hashfind(int key, Element & element)//búsqueda de tabla hash< / p>
{
int k = hashfunction(clave);
if (tabla[k]! = NULL)
{
Ele
ment *e=table[k];
while (e!=NULL)
{
if (e-gt; key == key)
{
elemento.key = e-gt;key;
element.code = e-gt;key;