UVa 213 Message Decoding
来源:互联网 发布:陈氏书法家 软件 编辑:程序博客网 时间:2024/06/06 07:44
输入部分包含两部分,编码头和一串code,注意序列与编码头的对应关系中,序列有着很强的分段规律性,所以选择二维数组code储存,最后解码时直接输出对应code元素即可。
源码如下
#include<iostream>#include<cstring>const int maxn = 80;char code[8][1 << 8];void readchar();int readint(int c);int main(){using namespace std;//int r = readint(3);//cout << r;readchar();//for (int a = 0; a < 1; a++)//cout << code[2][a];int m;while ((m=readint(3)) != 0){int j;//necessary?yeswhile ((j = readint(m)) != ((1 << m )- 1)){cout << code[m-1][j];}}}void readchar(){for (int i = 0; i < 8; i++)code[i][1 << 8] = {};using namespace std;char head[maxn];cin.getline(head, maxn);int len = strlen(head);int j = 0, k = 0;for (int i = 0; i < len; i++){code[j][k] = head[i];if ((k + 1) >= (1 << (j + 1)) - 1) { j++; k = 0; }else k++;}}int readint(int c){using namespace std;char ch;int ans=0;for (int i = 0; i < c; i++){while ((ch = cin.get()) == '\n')continue;ans += (ch - '0') << (c - i - 1);}return ans;}
阅读全文
0 0
- uva -213Message Decoding
- UVa 213 - Message Decoding
- UVA【213】 Message Decoding
- uva 213 Message Decoding
- UVA-213-Message Decoding
- UVa-213Message Decoding
- UVA - 213 Message Decoding
- Uva - 213 - Message Decoding
- UVA - 213 Message Decoding
- UVA 213 Message Decoding
- UVa 213 Message Decoding
- uva 213 Message Decoding
- UVa 213 Message Decoding
- UVA 213 Message Decoding
- Message Decoding UVa 213
- Uva 213 Message Decoding
- UVa 213 - Message Decoding
- UVa 213 - Message Decoding
- request.getparameter和 request.getattribute的区别
- poj1644分苹果
- maven package install deploy区别
- 【Leetcode 6】 ZigZag Conversion
- C语言基本数据类型转换
- UVa 213 Message Decoding
- 多表连接与聚合函数的查询问题
- 渲染管线——视图坐标与相机模型
- Git 执行更改
- Linux-gcc,gdb的安装与简单指令
- 如何向github提交更新
- Spring data JPA使用Specification实现动态查询例子
- 【翻译】MySQL-Tutorial ( 3 )
- Spring IOC -bean对象的生命周期详解