uvaoj 213 - Message Decoding(二进制,输入技巧)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=149
跨行读字符的函数readchar() 可以学习一下
把编码理解成二进制,用(len,value)这个二元组来表示一个编码,其中len是编码长度,value是编码对应的十进制数值
用code[len][value]保存这个编码所对应的字符
#include<bits/stdc++.h>
using namespace std;
int code[][<<];
int readchar()
{
for(;;)
{
int ch=getchar();
if(ch!='\n'&&ch!='\r')return ch;
}
}
int readint(int c)//读取接下来c个二进制字符,并返回十进制
{
int v=;
while(c--)v=v*+readchar()-'';
return v;
}
int readcodes()
{
memset(code,,sizeof(code));
code[][]=readchar();
for(int len=;len<=;len++)
{
for(int i=;i<(<<len)-;i++)
{
int ch=getchar();
if(ch==EOF)return ;
if(ch=='\n'||ch=='\r')return ;
code[len][i]=ch;
}
}
return ;
}
int main()
{
while(readcodes())
{
for(;;)
{
int len=readint();
if(len==)break;
for(;;)
{
int v=readint(len);
if(v==(<<len)-)break;
putchar(code[len][v]);
}
}
putchar('\n');
}
return ;
}
uvaoj 213 - Message Decoding(二进制,输入技巧)的更多相关文章
- UVA - 213 Message Decoding (输入字符串并对单个字符进行操作的输入输出)
POINT: 关于表示一个编码:利用code字符数组表示一个编码字符,其中code[len][val]表示长度为len,二进制值为val的字符: 主程序如下: #include <iostrea ...
- UVa 213 Message Decoding(World Finals1991,串)
Message Decoding Some message encoding schemes require that an encoded message be sent in two part ...
- uva 213 Message Decoding
思路来自紫书...开始时的思路估计100行+,果断放弃!关键:1.正确提取出函数! initmap():初始化字母与整数的映射. returnint(x):向后读取x位,并转换为十进制数返回. ...
- UVA 213 Message Decoding 【模拟】
题目链接: https://cn.vjudge.net/problem/UVA-213 https://uva.onlinejudge.org/index.php?option=com_onlinej ...
- 【每日一题】 UVA - 213 Message Decoding 模拟解码+读入函数+阅读题
题意:阅读理解难度一道比一道难orz.手摸了好久样例 题解: 读入:大循环用getline读入header顺便处理一下, 里面再写两重循环,外层一次读三个串,内层一次读num个串. 之后就查表,线性 ...
- uva 213 - Message Decoding (我认为我的方法要比书上少非常多代码,不保证好……)
#include<stdio.h> #include<math.h> #include<string.h> char s[250]; char a[10][250] ...
- Message Decoding UVA - 213
Some message encoding schemes require that an encoded message be sent in two parts. The fifirst par ...
- 【例题 4-4 uva 213】Message Decoding
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 输入的二进制长度最长为7 所以得开个sta[7][2^7]的样子才存的下所有的字符的.. 定义这么一个数组当字典. 然后一个字符一个 ...
- 4_4 信息解码(UVa213)<二进制:输入技巧与调试技巧>
消息编码方案要求在两个部分中发送一个被编码的消息.第一部分:称为头,包含消息的字符.第二部分包含一个模式 表示信息.你必须写一个程序,可以解码这个消息. 你的程序的编码方案的核心是一个序列的“0和1” ...
随机推荐
- 决策树在sklearn中的实现
1 概述 1.1 决策树是如何工作的 1.2 构建决策树 1.2.1 ID3算法构建决策树 1.2.2 简单实例 1.2.3 ID3的局限性 1.3 C4.5算法 & CART算法 1.3.1 ...
- javascript-数字转罗马数字
阿拉伯数字与罗马数字转换 罗马数字表示 XXI, 21 个位数举例I, 1 ]II, 2] III, 3] IV, 4 ]V, 5 ]VI, 6] VII, 7] VIII,8 ]IX, 9 ·十位数 ...
- 如何遍历Map操作总结
Map<Integer, String> map = new HashMap<Integer, String>(); map.put(1, "123"); ...
- win7环境中使用notepad++配置python IDE
1, 下载notepad++,并安装 http://notepad-plus-plus.org/download/v6.5.5.html 2, 下载python的win版本,并安装 https://w ...
- Hadoop 学习之——HDFS
HDFS是HADOOP中的核心技术之一——分布式文件存储系统.Hadoop的作者Doug Cutting 和Mike 是根据Google发布关于GFS 的研究报告所设计出的分布式文件存储系统. 一.H ...
- 【C++ Primer】读书笔记_第一章
Main(): 1. C++程序必须包含main()函数,操作系统通过调用main来运行C++程序. 2. main()的形参可以为空. 3. main函数的返回类型必须为int,返回给操作系统.in ...
- Zabbix——部署(agent和proxy安装)
前提条件: 已经完成对Zabbix-server的安装 已经完成对Mysql的安装 并且相互和正常使用和访问 配置agent服务器: rpm -Uvh https://repo.zabbix.com/ ...
- 安装mysql zip 安装包 Navicat连接
笔者在安装mysql时一直出现各种问题,今天难得成功一次,决定记录一下,留作纪念与参考 安装第一步,下载mysql https://dev.mysql.com/downloads/mysql/ 以在w ...
- JAVA中判断年月日格式是否正确(支持判断闰年的2月份)
一.先说一下年月日(yyyy-MM-dd)正则表达式: 1.年月日正则表达式:^((19|20)[0-9]{2})-((0?2-((0?[1-9])|([1-2][0-9])))|(0?(1|3|5| ...
- 使用EF Core的CodeFirt 出现的问题The specified framework version '2.1' could not be parsed
今天使用了一下EF Core的Code First,进行数据库迁移的的时候报错了: The specified framework version '2.1' could not be parsed ...