UVa 10878 Decode the tape
题目很简单,代码也很短。第一遍做的时候,我居然二乎乎的把input里面的小框框忽略掉了,所以WA了一次。
每一行代表一个二进制的ASCII码,'o'代表1,空格代表0,中间的小黑点忽略。
我直接把一行字符串全读进去,如果字符串以下划线开头说明输入结束(字符串的处理从第2行开始)。
然后从左到右一个字符一个字符的判断,是空格直接*2,是'o'先*2后加1,最后算出的就是对应的ASCII值。
Problem A
Decode the tape
Time Limit: 1 second
| "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 | Sample Output |
___________ |
A quick brown fox jumps over the lazy dog. |
Problemsetter: Igor Naverniouk
Special thanks: BSD games ppt.
//#define LOCAL
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std; int main(void)
{
#ifdef LOCAL
freopen("10878in.txt", "r", stdin);
#endif
int i;
char str[], ascii;
gets(str);
while(gets(str) && str[] != '_')
{
ascii = ;
for(i = ; i < strlen(str); ++i)
{
if(str[i] == ' ')
ascii *= ;
if(str[i] == 'o')
{
ascii *= ;
ascii += ;
}
}
printf("%c", ascii);
}
return ;
}
代码君
UVa 10878 Decode the tape的更多相关文章
- uva 10222 - Decode the Mad man
#include <iostream> #include <string> #include <cctype> using namespace std; int m ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- Volume 1. String(uva)
10361 - Automatic Poetry #include <iostream> #include <string> #include <cstdio> # ...
- 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 1(String)
第一题:401 - Palindromes UVA : http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8 ...
- UVA大模拟代码(白书训练计划1)UVA 401,10010,10361,537,409,10878,10815,644,10115,424,10106,465,10494
白书一:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=64609#overview 注意UVA没有PE之类的,如果PE了显示WA. UVA ...
- 图-用DFS求连通块- UVa 1103和用BFS求最短路-UVa816。
这道题目甚长, 代码也是甚长, 但是思路却不是太难.然而有好多代码实现的细节, 确是十分的巧妙. 对代码阅读能力, 代码理解能力, 代码实现能力, 代码实现技巧, DFS方法都大有裨益, 敬请有兴趣者 ...
- PC/UVa 题号: 110106/10033 Interpreter (解释器)题解 c语言版
, '\n'); #include<cstdio> #include<iostream> #include<string> #include<algorith ...
- POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for UNIX / UVAlive 5418 A Plug for UNIX / SCU 1671 A Plug for UNIX (网络流)
POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for ...
- uva 156 - Ananagrams (反片语)
csdn:https://blog.csdn.net/su_cicada/article/details/86710107 例题5-4 反片语(Ananagrams,Uva 156) 输入一些单词,找 ...
随机推荐
- Ajax风格的一款网页Loading效果
现在比较流行的一款Ajax风格的网页Loading,多见于一些大量使用Ajax技术的网站中,页面加载时会自动显示提示信息,带载入动画效果,网页加载完自动消失,是一款正在具有Loading功能的网页进度 ...
- [大牛翻译系列]Hadoop(5)MapReduce 排序:次排序(Secondary sort)
4.2 排序(SORT) 在MapReduce中,排序的目的有两个: MapReduce可以通过排序将Map输出的键分组.然后每组键调用一次reduce. 在某些需要排序的特定场景中,用户可以将作业( ...
- VMware下Ubuntu与宿主Windows共享文件夹
概述1.安装VMware Tool2.设置共享 步骤开始安装VMware Tool 显示如下画面(如果宿主无法访问外网,可能会出现一个更新失败,可以无视之) 通过下列命令解压.执行,分别是下面的tar ...
- lintcode:交换链表当中两个节点
题目 给你一个链表以及两个权值v1和v2,交换链表中权值为v1和v2的这两个节点.保证链表中节点权值各不相同,如果没有找到对应节点,那么什么也不用做. 注意事项 你需要交换两个节点而不是改变节点的权值 ...
- lintcode:等价二叉树
等价二叉树 检查两棵二叉树是否等价.等价的意思是说,首先两棵二叉树必须拥有相同的结构,并且每个对应位置上的节点上的数都相等. 样例 1 1 / \ / \ 2 2 and 2 2 / / 4 4 就是 ...
- CF 253B Two Heaps
#include<stdio.h> #include<algorithm> #include<map> using namespace std; struct No ...
- netbeans使用
下载地址 https://netbeans.org/downloads/ https://netbeans.org/downloads/start.html?platform=linux&la ...
- MongoDB使用SSL
1. MongoDB对SSL的支持情况 MongoDB社区版本不支持SSL,企业版提供对SSL的支持.MongoDB源代码中包含SSL的实现,可以自己编译带SSL的MongoDB. MongoDB支持 ...
- 317. Shortest Distance from All Buildings
题目: Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where th ...
- 308. Range Sum Query 2D - Mutable
题目: Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper ...