#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int main() //int avgc,char *avgv[];
{
int val1[20],val2[20],val3[20],val4[20];
int x,i,j,n,m,a,s;
clrscr();
cout<<"enter no .of generating fu.bits";
cin>>n;
cout<<"\n";
cout<<" enter gen.fu";
cout<<"\n ";
for (i=0;i<n;i++)
{
cin>>val1[i];
}
cout<<"gen.fu";
cout<<"\n";
for(i=0;i<n;i++)
{
cout<<val1[i];
}
cout<<"\n";
cout<<" enter no .of bits of polynomial";
cout<<"\n";
cin>>n;
cout<<"enter polynomial ";
cout<<"\n";
for(i=0;i<m;i++)
{
cin>>val2[i];
val4[i]=val2[i];
}
cout<<"\n";
cout<<" polynomial";
cout<<"n";
for(i=0;i<m;i++)
{
cout<<val2[i];
}
cout<<"\n";
cout<<"\n";
for(i=m;i<m+n-1;i++)
{
val2[i]=0;
}
cout<<"\n";
cout<<"appened polynomial i";
for(i=0;i<m+n-1;i++)
{
cout<<val2[i];
}
a=m+(n-1);
for(i=0;i<m;i++)
{
if(val2[i]==0)
{
for(i=1;j<n+i;++j)
val2[j]=val2[j]^0;
}
else
{
val2[i]=val2[i]^val2[0];
val2[i+1]=val2[i+1]^val1[1];
val2[i+2]=val2[i+2]^val1[2];
val2[i+3]=val2[i+3] ^val1[3];
}
}
cout<<"\n \t the crc is !";
for(i=m;i<a;++i)
cout<<val2[i];
for(i=m,j=m;j<a,i<m+n-1;j++,i++)
{
val4[i]=val2[j];
}
cout<<"crc matrix is :";
cout<<"\n";
for(i=0;i<m;i++)
{
if(val4[i]==0)
{
for(j=i;j<n+i;++j)
val4[j]=val4[i]^val1[0];
val4[i+1]=val4[i+1]^val1[1];
val4[i+2]=val4[i+2]^val1[2];
val4[i+3]=val4[i+3]^ val1[3];
}
}
cout<<"\n\t after error check is :";
for(i=m;i<a;i++)
{
cout<< val4[i];
}
cin>>x;
return 0;
}
No comments:
Post a Comment