⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 利用Visual C++编写M序列的生成以及利用给定的M序列采用采样技术生成其他的不同的序列
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -