#include <iostream> using namespace std; #define b(n) ((x>>(n))&0x01) void main() { int i,j,x,y1,y2,y3,b[10]; //First build 10 mask bits: for(i=0; i<10; i++) { b[i] = 1<<i; } x = 372; // seed number for(j=0;j<10;j++) { //rotate x to the left, and copy the exclusive or of bits 9, 8 and 0 into bit 0: y1 = (b[9] & x) ? 1 : 0; y2 = (b[8] & x) ? 1 : 0; y3 = (b[0] & x) ? 1 : 0; x = x << 1 | (y1^y2^y3); // show result for(int i=0;i<10;i++) { cout<<b(10-i)<<" "; } cout<<endl; } }

output::

hi all i have problem with 10 bits LFSR random number generator in c++

for result number is binary i want show number as decimal

thank all