data_generator.c

来自「软输出维特比译码算法的C语言详细实现,程序效率高,比MATLAB快多了.」· C语言 代码 · 共 27 行

C
27
字号
/* 0/1 DATA GENERATOR                                               */
/* Copyright (c) 1999, Spectrum Applications, Derwood, MD, USA      */
/* All rights reserved                                              */
/* Version 2.0 Last Modified 1999.02.17                             */
 
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
 
#include "vdsim.h"
 
void gen01dat( long data_len, int *out_array ) {
 
    long t;            /* time */

    /* re-seed the random number generator */
    srand( (unsigned)time( NULL ) );


    /* generate the random data and write it to the output array */
    for (t = 0; t < data_len; t++)
        *( out_array + t ) = (int)( rand() / (RAND_MAX / 2) > 0.5 );

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?