main.cpp
来自「利用Visual C++编写M序列的生成以及利用给定的M序列采用采样技术生成其他」· C++ 代码 · 共 42 行
CPP
42 行
#include "mSequence.cpp"
#include <stdio.h>
#include <iostream>
void main()
{
int i,p,m,mSeqLength,sequence[1000];
//complex<double> complex1;
FILE *fp;
char filename[10];
//Input the number: p,m
cout<<"Please input the numbers:p m\np=2:binary\np=3:ternary\nor p=5,7,11,13,17,19,23,29,31\nm:the degree\np=2,4 : m=1-100\np=3 : m=1-10\np=5 : m=1-5\np=7 : m=1-4\notherwise m=2 or 3\n";
cin>>p>>m;
cout<<"please input the filename that we can write data on:\n";
scanf("%s",filename);
if ((fp=fopen(filename,"w"))==NULL)
{
printf("cannot open file\n");
exit(0);
}
mSequence(p,m,sequence);
mSeqLength=(int)pow(p,m)-1;
fprintf(fp,"p=%d,m=%d,the pseudo-random sequence with the length %d as following:\n",p,m,mSeqLength);
if (p<10)
for (i=0;i<mSeqLength;i++)
{if (i%5==0)
fprintf(fp," ");
fprintf(fp,"%d",sequence[i]);
}
else
for (i=0;i<mSeqLength;i++)
fprintf(fp,"%3d",sequence[i+m]);
fclose(fp);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?