UVA - 10878 Decode the tape

Description

 

"Machines take me by surprise with great frequency."

Alan Turing

Your boss has just unearthed a roll of old computer tapes. The tapes have holes in them and might contain some sort of useful information. It falls to you to figure out what is written on them.

Input

The input will contain one tape.

Output

Output the message that is written on the tape.

Sample Input

___________
| o   .  o|
|  o  .   |
| ooo .  o|
| ooo .o o|
| oo o.  o|
| oo  . oo|
| oo o. oo|
|  o  .   |
| oo  . o |
| ooo . o |
| oo o.ooo|
| ooo .ooo|
| oo o.oo |
|  o  .   |
| oo  .oo |
| oo o.ooo|
| oooo.   |
|  o  .   |
| oo o. o |
| ooo .o o|
| oo o.o o|
| ooo .   |
| ooo . oo|
|  o  .   |
| oo o.ooo|
| ooo .oo |
| oo  .o o|
| ooo . o |
|  o  .   |
| ooo .o  |
| oo o.   |
| oo  .o o|
|  o  .   |
| oo o.o  |
| oo  .  o|
| oooo. o |
| oooo.  o|
|  o  .   |
| oo  .o  |
| oo o.ooo|
| oo  .ooo|
|  o o.oo |
|    o. o |
___________

Sample Output

A quick brown fox jumps over the lazy dog.
题意:观察题,空格代表二进制的0,‘o’代表1
思路:处理输出
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;

int f[11] = {0,0,64,32,16,8,0,4,2,1,0};  

int main() {
	char str[12];
	gets(str);
	while (gets(str) && str[0] != '_') {
		int ans = 0;
		for (int i = 2; i < 10; i++)
			if (str[i] == 'o')
				ans += f[i];
		printf("%c", ans);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!感谢您的提问。我理解您的问题是关于如何在 TensorFlow 中对 UTF-8 编码的 TFRecord 进行解码。 首先,TFRecord 是 TensorFlow 中的一种数据格式,它可以有效地存储大量的数据,并且可以被 TensorFlow 的数据读取器读取。在使用 TFRecord 时,我们需要将数据序列化为 TFRecord 格式,然后再进行存储和读取。 对于包含 UTF-8 编码的字符串的 TFRecord,我们可以使用 TensorFlow 的解码函数来进行解码。具体地,可以使用 tf.io.parse_single_example 函数来解析一个 TFRecord,并使用 tf.io.decode_raw 函数对字符串进行解码。示例代码如下: ```python import tensorflow as tf # 定义 TFRecord 文件名和解码函数 filename = 'data.tfrecord' def decode_record(record): features = { 'text': tf.io.FixedLenFeature([], tf.string) } example = tf.io.parse_single_example(record, features) text = tf.io.decode_raw(example['text'], tf.uint8) text = tf.reshape(text, [-1]) text = tf.strings.unicode_decode(text, 'UTF-8') return text # 读取 TFRecord 文件 dataset = tf.data.TFRecordDataset(filename) # 对 TFRecord 进行解码 dataset = dataset.map(decode_record) ``` 在上面的代码中,我们首先定义了一个 TFRecord 文件名和一个解码函数 decode_record。解码函数将一个 TFRecord 解析为一个字典,其中包含一个字符串字段 text。然后,我们使用 tf.io.decode_raw 函数将字符串转换为字节数组,再使用 tf.strings.unicode_decode 函数将字节数组解码为 UTF-8 编码的字符串。 最后,我们使用 tf.data.TFRecordDataset 函数读取 TFRecord 文件,并使用 map 函数对每个 TFRecord 进行解码。 希望这个回答能够解决您的问题。如果您有任何其他疑问,请随时提出。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值