#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); file://形成f0 f.push_back(temp); file://把f0加到f数组中。 do{ int dn =0; for (int i = 0;i<=l[n];++i) { |