莫尔斯代码的c语言编码,c语言编写莫尔斯码,帮帮忙啊,速回

/*英文转摩尔斯码*/

#include

main()

{

char a[26][6]={{'。','-'},{'-','。','。','。'},{'-','。','-','。'},{'-','。','。'},

{'。

'},{'。','。','-','。'},{'-','-','。'},{'。','。','。','。'},

{'。','。'},{'。','-','-','-'},{'-','。','-'},{'。','-','。','。

'},

{'-','-'},{'-','。'},{'-','-','-'},{'。','-','-','。'},

{'-','-','。','-'},{'。','-','。'},{'。','。','。

'},{'-'},

{'。','。','-'},{'。','。','。','-'},{'。','-','-'},{'-','。','。','-'},

{'-','。','-','-'},{'-','-','。

','。'}};

int i,m;char str[100];

char c;

gets(str);

printf("%s",str);

for (i=0;(c=str[i])!='\0';i++)

if(c==' ') printf(" ");

else

printf("%s",a[m=str[i]-97]),printf(" ");

printf("\n");

getchar();

}

/*摩尔斯码转英文*/

#include

#include

main()

{

char a[26][6]={{'。

','-'},{'-','。','。','。'},{'-','。','-','。'},{'-','。','。'},

{'。'},{'。','。','-','。'},{'-','-','。'},{'。','。','。','。

'},

{'。','。'},{'。','-','-','-'},{'-','。','-'},{'。','-','。','。'},

{'-','-'},{'-','。'},{'-','-','-'},{'。

','-','-','。'},

{'-','-','。','-'},{'。','-','。'},{'。','。','。'},{'-'},

{'。','。','-'},{'。','。','。','-'},{'。

','-','-'},{'-','。','。','-'},

{'-','。','-','-'},{'-','-','。','。

'}};

int b,i,m;char str[100],k;

char c,*p,t[6];

gets(str);

printf("%s",str);

p=str;

while(*p!='\0')

{

i=0;

b=0;

k=0;

while(*p!=' '&&*p!='\0')

{

t[i++]=*p;

p++;

}

t[i]='\0';

while(strcmp(a[k++],t)!=0);

c=k-1+97;

putchar(c);

while(*p==' ') {b++;p++;}

if(b==3) printf(" ");

}

getchar();

return(0);

}

其他的不懂。

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值