如何用matlab做出LDPC码与RS码、BCH码的增益仿真比较
发布网友
发布时间:2022-04-23 11:28
我来回答
共1个回答
热心网友
时间:2023-08-26 12:14
#include <iostream>
#include <limits>
#define LNODE 20
using namespace std;
#include <malloc.h>
#include <conio.h>
typedef char **HuffmanCode;
HuffmanCode HuffmanCoding(int n)
{
int i , f , start , j , count = 1;
char *cd;
HuffmanCode HC;
HC = (HuffmanCode)malloc((n+1)*sizeof(char *));
cd = (char *)malloc(n*sizeof(char));
cd[n-1] = '\0';
for(i = 1 ; i <= n ; i++)
{
start = n - 1;
for(j = 1 ; j <= count ; j++){
cd[--start] = '9';
}
HC[i] = (char *)malloc((n-start)*sizeof(char));
strcpy(HC[i],&cd[start]);
count++;
}
free(cd);
return(HC);
}//HuffmanCoding
int main()
{
int k;
int A[LNODE];
HuffmanCode q;
q = HuffmanCoding(LNODE);
for(k = 1 ; k <= LNODE ; k++)
cout << *q[k] << " ";
cout << "OK";
getch();
return 0;
}