📄 decodebwt.c
字号:
#include <stdlib.h>#include <string.h>#include <stdio.h> typedef unsigned char byte; //declaramos nuevo tipo de dato: unsigned char al que llamamos byte <de 0 a 255> //byte *rotlexcmp_buf = NULL; //buffer para la cadena a codificarvoid bwt_decode(byte *buf_in, byte *buf_out, int size, int llave) { int tabla[256]; int i,j,sum; int indices[size]; memset( tabla, 0, sizeof( tabla ) ); // inicializa en ceros el array for (i=0; i<size; i++) indices[i] = tabla[buf_in[i]]++; for (sum=i=0; i<256; i++) { int __t = tabla[i]; tabla[i] = sum; sum += __t; } for(j=llave,i=size; i--; j=indices[j] + tabla[buf_in[j]] ) buf_out[i] = buf_in[j];}int main() { byte buf2[255]; byte buf3[255]; int llave; // = 3; printf ("Palabra a decodificar: "); scanf("%s",buf2); printf ("Introduce la llave: "); scanf("%d",&llave); bwt_decode (buf2, buf3, strlen((const char*)buf2), llave); printf ("Decodificado: %.*s\n", strlen((const char*)buf2), buf3); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -