/*
Name: 梅西迭代算法的实现
Copyright: 2003(C)
Author: 徐岩柏
Date: 31-10-03 16:09
Description: 该问题是线性移位寄存器的综合问题提出的,给定一个N长的
二元序列,如何求出产生这一序列的级数最小的线性移位寄存
器,即最短的线性移位寄存器
*/
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
typedef vector<bool> MyArray; file://定义自己的数据类
MyArray a; file://状态数组 ,用来保存给定的m序列?
vector<int>l; file://线性移位寄存器的级数数组
MyArray temp;
vector<MyArray> f; file://为线性移位寄存器对应的多项式
int N =0;
ifstream infile("input.txt"); file://从文件中读取数据
ofstream outfile("output.txt"); file://把结果写入文件中。
if(!infile)
{
cout << "Aata file input.txt is not ready! Please check it"<<endl;
exit (-1);
}
string strTemp;
infile>>strTemp; file://读入N
// cout << strTemp <<endl;
N = atoi(strTemp.c_str());
infile>>strTemp; file://读入序列
for( int i = 0 ;i<N; ++i)
{
a.push_back(strTemp[i]=='1'); file://把序列保存
}
file://cout << strTemp <<endl;
int n=0;
l.push_back(0);
temp.push_back(1); fi

这段代码展示了如何用C++实现梅西迭代算法,用于解决线性移位寄存器的综合问题。程序从文件中读取数据,计算并输出产生给定二元序列的最短线性移位寄存器的级数和多项式。
最低0.47元/天 解锁文章
942

被折叠的 条评论
为什么被折叠?



