博客
关于我
算法提高 9-3摩尔斯电码 map
阅读量:445 次
发布时间:2019-03-06

本文共 1476 字,大约阅读时间需要 4 分钟。

算法提高 9-3摩尔斯电码  
时间限制:1.0s   内存限制:256.0MB
   
问题描述
  摩尔斯电码破译。类似于乔林教材第213页的例6.5,要求输入摩尔斯码,返回英文。请不要使用"zylib.h",只能使用标准库函数。用' * '表示' . ',中间空格用' | '表示,只转化字符表。
  摩尔斯码定义见:http://baike.baidu.com/view/84585.htm?fromId=253988。
提示
  清橙进行评测时,输入是以EOF结尾的,而不是换行符。(EOF不是一个字符,“以EOF结尾”是一种通俗但不严谨的说法。)因此可以通过以下方式之一获取输入:
  1. 一次读入整行字符串,再进行后续解析。
  2. 使用getchar或scanf一次读入一个字符,通过它们的返回值判断输入结束。
样例输出

代码:

#include
#include
#include
#include
#include
using namespace std;map
Map;void init(){ Map.insert(make_pair("*-",'a')); Map.insert(make_pair("-***",'b')); Map.insert(make_pair("-*-*",'c')); Map.insert(make_pair("-**",'d')); Map.insert(make_pair("*",'e')); Map.insert(make_pair("**-*",'f')); Map.insert(make_pair("--*",'g')); Map.insert(make_pair("****",'h')); Map.insert(make_pair("**",'i')); Map.insert(make_pair("*---",'j')); Map.insert(make_pair("-*-",'k')); Map.insert(make_pair("*-**",'l')); Map.insert(make_pair("--",'m')); Map.insert(make_pair("-*",'n')); Map.insert(make_pair("---",'o')); Map.insert(make_pair("*--*",'p')); Map.insert(make_pair("--*-",'q')); Map.insert(make_pair("*-*",'r')); Map.insert(make_pair("***",'s')); Map.insert(make_pair("-",'t')); Map.insert(make_pair("**-",'u')); Map.insert(make_pair("***-",'v')); Map.insert(make_pair("*--",'w')); Map.insert(make_pair("-**-",'x')); Map.insert(make_pair("-*--",'y')); Map.insert(make_pair("--**",'z'));}int main(){ string s; init(); cin>>s; int len=s.length(); int l=0,r=0; while(r

转载地址:http://mpjyz.baihongyu.com/

你可能感兴趣的文章
mysql workbench6.3.5_MySQL Workbench
查看>>
MySQL Workbench安装教程以及菜单汉化
查看>>
MySQL Xtrabackup 安装、备份、恢复
查看>>
mysql [Err] 1436 - Thread stack overrun: 129464 bytes used of a 286720 byte stack, and 160000 bytes
查看>>
MySQL _ MySQL常用操作
查看>>
MySQL – 导出数据成csv
查看>>
MySQL —— 在CentOS9下安装MySQL
查看>>
MySQL —— 视图
查看>>
mysql 不区分大小写
查看>>
mysql 两列互转
查看>>
MySQL 中开启二进制日志(Binlog)
查看>>
MySQL 中文问题
查看>>
MySQL 中日志的面试题总结
查看>>
mysql 中的all,5分钟了解MySQL5.7中union all用法的黑科技
查看>>
MySQL 中的外键检查设置:SET FOREIGN_KEY_CHECKS = 1
查看>>
Mysql 中的日期时间字符串查询
查看>>
mysql 中索引的问题
查看>>
MySQL 中锁的面试题总结
查看>>
MySQL 中随机抽样:order by rand limit 的替代方案
查看>>
MySQL 为什么需要两阶段提交?
查看>>