当前位置: 首页 > 工具软件 > Tape > 使用案例 >

UVA 10878 - Decode the tape

贲骏喆
2023-12-01

看到题目的第一眼我的蛋就疼了...瞬间想起了莫尔斯码╮(╯▽╰)╭

难道ACM还考察密码学的知识....

看了十几分钟找不到头绪,果断看了其他人的结题报告..泥马..把二进制写成这个样子的人也算是个人才了ORZ.

题目挺简单的,但是大部分人都是先把二进制写出来,再转化为十进制输出.忽然,我看到了一个与众不同的写法...

其实略微想一下,Input的格式都是对齐的,所以只需计算1的位权就可以了,而每位的位权都可以写出来.

这样就省去了转化的步骤..


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	int num[] = {0,0,64,32,16,8,0,4,2,1};
	int asc = 0;
	//freopen("input.txt","r",stdin);
	int i = 0;
	char temp[50];
	while (gets(temp))
	{
		asc = 0;
		if (temp[0] != '|')
			continue;
		for (i = 2; i < 11; i++)
		{
			if (temp[i] == 'o')
				asc += num[i];
		}
		printf("%c",asc);
	}
	return 0;			
}


 类似资料:

相关阅读

相关文章

相关问答