#include "math.h"
#include "stdlib.h"
#include "stdio.h"
#include "time.h"
#include "malloc.h"
#include "string.h"
#include "iostream.h"
#define source_length 1000000
#define symbol_length source_length/2
#define SNR_start 1
#define SNR_end 10
#define SNR_step 1
#define PI 3.1415926
#define Coderate 1
typedef struct {
double Rpart;
double Ipart;
}complex;
int source[source_length];//message(),modulate(),error()
int change[source_length];//modulate()
int resource[source_length]; //demodulate(),error()
complex modulatesym[symbol_length]; //demodulate(),channel(),moudulate()
int snr;//channel(),error()
int errorbit, errorsym;//error()
double BER,SER;//error()
void message();
void modulate(int source[source_length]);
void channel(complex modulatesym[symbol_length],int snr);
void demodulate();
void error();
//随机信号产生
void message()
{
int i;
//以当前时间作为时间种子
srand((unsigned)time(NULL));
//产生0,1随机信号
for(i=0;i<source_length;i++)
{ source[i]=rand()%2;
//cout<<source[i];
}
//cout<<endl;
}