博客
关于我
算法提高 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 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>
mysql 死锁(先delete 后insert)日志分析
查看>>
MySQL 死锁了,怎么办?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 添加列,修改列,删除列
查看>>
mysql 添加索引
查看>>
MySQL 添加索引,删除索引及其用法
查看>>
mysql 状态检查,备份,修复
查看>>
MySQL 用 limit 为什么会影响性能?
查看>>