饮水思源站 | 文章阅读 | 精华区离线浏览 |
---|
发信人: daneestone (关二哥), 信区: outdoor 标 题: TURBO C 摩斯码与英文互换 发信站: 饮水思源 (2005年10月05日14:48:31 星期三) 英文转摩尔斯码 #include<stdio.h> 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<stdio.h> #include<string.h> 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); } --Dave Finley, N1IRZ(译文有删节) ----------------------------------------------------------- 关于莫尔斯码训练的完整信息、CW操作、历史和更多,请参见作者的书:莫尔斯码:突破障碍(Morse Code: Breaking the Barrier),由MFJ Enterprises, Inc.出版。 NIOBIUM,源自Niobe,希腊神话财富王女儿之名。曾称为钶(Columbium), 醉 闾 颇诗意的南美地名,铌最初发现于此。冷却至接近绝对零度时,可作超导体。 后 巷 CERIUM,为纪念火星与木星间小行星谷神星Ceres而取名,稀土元素中最丰富。 乱 狂 是“混合金属”的主要构成者(近半)。 涂 徒 COPPER源自Cuprum,产铜闻名的塞浦路斯岛古名。与金为仅两种有除灰白黑以外颜色的金属。 纯铜是玫瑰红色的。 ※ 来源:·饮水思源 bbs.sjtu.edu.cn·[FROM: 211.80.63.153] ※ 修改:·daneestone 于 10月05日15:04:45 修改本文·[FROM: 211.80.63.153] |
返回 |
Copyright © 2001 SJTUBBS, All Rights Reserved.
版权所有上海交大BBS饮水思源站