/*英文转摩尔斯码*/
#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);
}
其他的不懂。
全部