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) 输入一些单词,找 ...
随机推荐
- c3p0 --1
# # This file is detritus from various testing attempts # the values below may change, and often do ...
- 旨在脱离后端环境的前端开发套件 - IDT Server篇
IDT,一个基于Nodejs的,旨在脱离后端环境的前端开发套件,目的就是能让前端开发完全脱离后端的环境,无论后端是什么模板引擎(主流),都能应付自如. IDT主要包括两大部分:Server + Bui ...
- 【mysql5.6】连接vs2010
参考这篇博客:http://www.tuicool.com/articles/mUZNne 配置:vs2010项目属性里面配置包含目录和库目录. 包含目录:C:\Program Files\MySQL ...
- 【LA3942-Remember the word 】Trie
http://acm.hust.edu.cn/vjudge/problem/22109 题意:给定n个单词,一个字符串,问把这个字符串划分为若干个单词的连接(单词可重复使用)有多少种方案(mod200 ...
- 解决安装rpm时lib冲突:libstdc++-2-libc6.1-1-2.9.0.so from install of compat-libstdc++-7.3-2.96.118 conflicts with file from ...
sudo rpm -ivh xxx.rpm -aid --force [oracle@localhost Oracle]$ .i386.rpm compat-libstdc++-devel-.i386 ...
- SSH开发实践part4:Spring整合Struts
1 好了,前面spring与hibernate的整合开发我们基本上讲完了,现在要开始服务层的开发,也就是处理事务的action,在这里我们需要引入spring与struts的整合.也就是将action ...
- C#获取根目录的方法集合
1.取得控制台应用程序的根目录方法 方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径 方法2.AppDomain.Curren ...
- STL erase函数
1 各种迭代器erase实现 析构的基本工具 Template <class T> inline void destroy(T* pointer){ pointer->~T(); } ...
- SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-003编写JPA-based repository( @PersistenceUnit、 @PersistenceContext、PersistenceAnnotationBeanPostProcessor)
一.注入EntityManagerFactory的方式 package com.habuma.spittr.persistence; import java.util.List; import jav ...
- ThreadLocal,ThreadLocalMap,Thread 的相互关系
1.ThreadLocal. 真正关键的类是它的内部类ThreadLocalMap,ThreadLocal 基本上相当于一个代理,或者算是Facade模式的应用,还没想清楚这种设计的妙处.(经过分析, ...