-
大小: 6KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-05-25
- 語言: C/C++
- 標簽: Manchester??
資源簡介
使用C語言編寫的曼徹斯特編碼和解碼功能函數(shù)

代碼片段和文件信息
#include
#include
#include
const?int?size=10;
void?Display()
{
cout<<“\nselect?what?you?want?to?do:“< cout<<“0.Exit“;
cout<<“1.Manchester?encoding.“< cout<<“2.Differential?Manchester?encoding.“< cout<<“3.Translate?the?Manchester?code?into?original?one.“< cout<<“4.Translate?the?Differential?Manchester?code?into?original?one.“< }
/*void?Encipher_M(char?code[])???//Manchester?Encoding
{
int?ilen;
len=strlen(code);
cout<<“the?Manchester?code?is:?“;
for(i=0;i {
if(code[i]==‘1‘)
cout<<“10“;
else?cout<<“01“;
}
cout< }
void?Encipher_DM(char?code[])??//Differential?Manchester?Encoding
{
int?ilena[2*size];
len=strlen(code);
cout<<“the?Differential?Manchester?code?is:?“;
if(code[0]==‘1‘)
{
a[0]=1;?a[1]=0;
}
else?{
a[0]=0;?a[1]=1;
}
for(i=1;i {
???if(code[i]==‘0‘)
????if(a[2*i-1]==0){
a[2*i]=1;?a[2*i+1]=0;
}
???else{
a[2*i]=0;?a[2*i+1]=1;
}
???else
if(a[2*i-1]==0){
a[2*i]=0;?a[2*i+1]=1;
}
else{
a[2*i]=1;?a[2*i+1]=0;
};
}
for(i=0;i<2*len;i++)
cout< cout< }*/
void?Decipher_M(char?code[])?//translate?the?Manchester?code?to?original?one.
{
int?ilena[size];
len=strlen(code);
while(len%2)
{
cout<<“the?Manchester?code?input?is?wrong.please?input?again:“< cin>>code;
len=strlen(code);
}
while(len>size*2)?
{
cout<<“the?code?input?is?beyond?length?limit.please?input?again:“< cin>>code;
len=strlen(code);
}
??for(i=0;i {
if(code[i]==‘0‘&&code[i+1]==‘1‘)?
{
a[i/2]=0;
}
else?if(code[i]==‘1‘&&code[i+1]==‘0‘)
{
a[i/2]=1;
}
else?
{
cout<<“the?Manchester?code?input?is?wrongcan‘t?translate?into?original?code.“< return;//想在如果出現(xiàn)這個ELSE情況的時候就跳出FOR循環(huán)。。。。
}
}????
for(i=0;i {
cout< }?
cout< }
/*void?Decipher_DM(char?code[])?//translate?Differential?Manchester?code?into?original?one.
{
int?ilena[size];
len=strlen(code);
while(len%2)
{
cout<<“the?Differential?Manchester?code?input?is?wrong.please?input?again:“< cin>>code;
len=strlen(code);
}
while(len>size*2)?
{
cout<<“the?code?input?is?beyond?length?limit.please?input?again:“< cin>>code;
len=strlen(code);
}
if(code[0]==‘0‘&&code[1]==‘1‘)?a[0]=0;
else?if(code[0]==‘1‘&&code[1]==‘0‘)?a[0]=1;
else?cout<<“the?code?input?is?wrong.can‘t?translate?into?original?code.“< for(i=2;i {
if(code[i-1]==‘0‘)
if(code[i]==‘0‘&&code[i+1]==‘1‘)?a[i/2]=1;
else?if(code[i]==‘1‘&&code[i+1]==‘0‘)?a[i/2]=0;
?????else?cout<<“the?code?input?is?wrong.can‘t?translate?into?original?code.“< else?if(code[i-1]==‘1‘)
if(code[i]==‘1‘&&code[i+1]==‘0‘)?a[i/2]=1;
else?if(code[i]==‘0‘&&code[i+1]==‘1‘)?a[i/2]=0;
?????else?cout<<“the?code?input?is?wrong.can‘t?translat
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-10-22?19:45??Manchester\Debug\
?????文件????????3524??2017-10-22?17:25??Manchester\Manchester.cpp
?????文件????????4332??2005-04-03?23:28??Manchester\Manchester.dsp
?????文件?????????543??2005-04-03?23:12??Manchester\Manchester.dsw
?????文件???????41984??2005-04-05?22:20??Manchester\Manchester.ncb
?????文件???????48640??2005-04-05?22:20??Manchester\Manchester.opt
?????文件????????1296??2005-04-03?23:28??Manchester\Manchester.plg
?????目錄???????????0??2005-04-05?22:20??Manchester\
評論
共有 條評論