#include<iostream>
using namespace std;
int main(){
bool bit[20];int i,n;
char t='L';
cout<<"\nEnter the total bit size:";
cin>>n;
cout<<"\nEnter the bits with spaces:";
for(i=0;i<n;i++){
cin>>bit[i];
}
cout<<"\nNRZ ";
for(i=0;i<n;i++){
if(bit[i]==0)
cout<<"L ";
else
cout<<"H ";
}
cout<<"\n\nNRZI ";
cout<<"L ";
for(i=1;i<n;i++){
if(bit[i]==1)
{
if(t=='H')
{
t='L';
}
else
t='H';
}
cout<<t<<" ";
}
cout<<"\nMANCHASTER ";
for(i=0;i<n;i++){
if(bit[i]==0)
cout<<"LH";
else
cout<<"HL";
}
return 0;
}
using namespace std;
int main(){
bool bit[20];int i,n;
char t='L';
cout<<"\nEnter the total bit size:";
cin>>n;
cout<<"\nEnter the bits with spaces:";
for(i=0;i<n;i++){
cin>>bit[i];
}
cout<<"\nNRZ ";
for(i=0;i<n;i++){
if(bit[i]==0)
cout<<"L ";
else
cout<<"H ";
}
cout<<"\n\nNRZI ";
cout<<"L ";
for(i=1;i<n;i++){
if(bit[i]==1)
{
if(t=='H')
{
t='L';
}
else
t='H';
}
cout<<t<<" ";
}
cout<<"\nMANCHASTER ";
for(i=0;i<n;i++){
if(bit[i]==0)
cout<<"LH";
else
cout<<"HL";
}
return 0;
}
No comments:
Post a Comment