uva 213 - Message Decoding (我认为我的方法要比书上少非常多代码,不保证好……)
#include<stdio.h>
#include<math.h>
#include<string.h>
char s[250];
char a[10][250];
int a1[4];
int a2[250];
char ch; int init(int len)
{
int tt=0;
for(int i=1;i<=7;i++)
{
for(int j=0;j<(int)pow(2,i)-1;j++)
{
a[i][j]=s[tt++];
if(tt>=len)
break;
}
if(tt>=len)
break;
}
} int tran(int *aa,int len)
{
int temp=0;
for(int i=len-1,j=0; i>=0; i--,j++)
{
temp+=(int)aa[i]*pow(2,j);
}
return temp;
} int main()
{
while(gets(s)!=NULL)
{
memset(a,0,sizeof(a));
int len=strlen(s);
init(len); while(1)
{
int t2=0;
while(t2<3)
{
scanf("%c",&ch);
if(ch=='1'||ch=='0')
{
a1[t2]=ch-'0';
t2++;
}
}
int lenth=tran(a1,3);
if(lenth==0)
{
scanf("%c",&ch);
printf("\n");
break;
}
while(1)
{
int t3=0;
while(t3<lenth)
{
scanf("%c",&ch);
if(ch=='1'||ch=='0')
{
a2[t3]=ch-'0';
t3++;
}
}
int ans=tran(a2,lenth);
if(ans!=(int)pow(2,lenth)-1)
printf("%c",a[lenth][ans]);
else
break;
}
}
}
return 0;
}
uva 213 - Message Decoding (我认为我的方法要比书上少非常多代码,不保证好……)的更多相关文章
- 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 【模拟】
题目链接: https://cn.vjudge.net/problem/UVA-213 https://uva.onlinejudge.org/index.php?option=com_onlinej ...
- uva 213 Message Decoding
思路来自紫书...开始时的思路估计100行+,果断放弃!关键:1.正确提取出函数! initmap():初始化字母与整数的映射. returnint(x):向后读取x位,并转换为十进制数返回. ...
- UVA - 213 Message Decoding (输入字符串并对单个字符进行操作的输入输出)
POINT: 关于表示一个编码:利用code字符数组表示一个编码字符,其中code[len][val]表示长度为len,二进制值为val的字符: 主程序如下: #include <iostrea ...
- 【每日一题】 UVA - 213 Message Decoding 模拟解码+读入函数+阅读题
题意:阅读理解难度一道比一道难orz.手摸了好久样例 题解: 读入:大循环用getline读入header顺便处理一下, 里面再写两重循环,外层一次读三个串,内层一次读num个串. 之后就查表,线性 ...
- uvaoj 213 - Message Decoding(二进制,输入技巧)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 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]的样子才存的下所有的字符的.. 定义这么一个数组当字典. 然后一个字符一个 ...
- UVa 213,World Finals 1991,信息解码
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
随机推荐
- Codeforces Round #295 (Div. 2)B - Two Buttons BFS
B. Two Buttons time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- String s="hello";s+="world";s变化了吗?原始的String对象的内容变了吗?
分析: String s="hello";s+="world"; 引用变量s 一开始指向String对象("hello" :0x001); ...
- [转载] 使用Kettle进行数据迁移(ETL)
由于开发新的系统,需要将之前一个老的C/S应用的数据按照新的数据设计导入到新库中.此过程可能涉及到表结构不一致.大数据量(千万级,甚至上亿)等情况,包括异构数据的抽取.清洗等等工作.部分复杂的工作需要 ...
- configure: error: libpam required but missing
安装pam-devel:yum install pam-devel
- Linux服务器压测/拷机软件收集
最近公司采购了一批服务器,于是收集了一些拷机软件来压测服务器硬件性能.硬件的稳定相对来说比较重要,7x24小时无间断运行,主要看三个硬件:CPU.内存.硬盘. 下面是收集的一些教程,可能网址已经失效了 ...
- Html.BeginForm() vs Ajax.BeginForm() in MVC3
我们知道,BeginForm()方法能创建一个Form标签,因此可以结合表单级的方法,在这个页面中.我一直在考虑Html.BeginForm()方法和Ajax.BeginForm()方法在MVC3中有 ...
- 转 iOS 调试技巧
调度技巧一: 程序在崩溃的时候,xcode经常没有给出准确的堆栈信息,而是定位在了main方法里,这个让人很是头疼,又怀念起了vs, 其实xcode只要装简单设置一下,就能准确给出堆栈信息了, 打开 ...
- python文本 单独处理每个字符的方法汇总
python文本 单独处理字符串每个字符的方法汇总 场景: 用每次处理一个字符的方式处理字符串 方法: 1.使用list(str) >>> a='abcdefg' >&g ...
- iframe在ie和firefox中的高度兼容性问题解决
1.问题描述: <iframe src="p_photo_cont_iframe.html" name="iframe" width="700& ...
- 分享JavaScript获取网页关闭与取消关闭的事件
在做Web开发时,我们经常用到页面关闭事件onbeforeunload,可以给用户一个选择放弃关闭的机会,就比如这个博客编辑器.如果用户选择了离开,那么onunload事件自然会触发:但若用户选择了取 ...