zoukankan      html  css  js  c++  java
  • UVa 10878 Decode the tape

    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
    ___________
    | 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 |
    ___________
    
    A quick brown fox jumps over the lazy dog.
    

    Problemsetter: Igor Naverniouk
    Special thanks: BSD games ppt.

    从样例输入输出可以很容易看出,输入纸带的每一行是一个ASCII表示的字符,'o'表示1,' '表示0,中间的'.'是个干扰字符,删去即可

    写程序每次读一行,算出ASCII码值输出字符即可

     1 #include<iostream>
     2 #include<cstdio>
     3 
     4 using namespace std;
     5 
     6 char s[20];
     7 
     8 int main()
     9 {
    10     gets(s);
    11 
    12     while(gets(s))
    13     {
    14         if(s[0]=='_')
    15             break;
    16 
    17         for(int i=6;i<=8;i++)
    18             s[i]=s[i+1];
    19 
    20         int res=0;
    21 
    22         for(int i=1;i<=8;i++)
    23         {
    24             if(s[i]=='o')
    25                 res+=(1<<(8-i));
    26         }
    27 
    28         putchar(res);
    29     }
    30 
    31     return 0;
    32 }
    [C++]
  • 相关阅读:
    关于工作习惯的一点思考
    BulkSqlCopy 批量导入数据(Ef支持)
    记录下最近项目中常用到的SQL语句
    对象化前端表单(Form)提交
    Python描述符 (descriptor) 详解
    Python装饰器之 property()
    Python魔法方法之属性访问 ( __getattr__, __getattribute__, __setattr__, __delattr__ )
    Python魔法方法总结及注意事项
    面向对象编程(二)
    面向对象编程(一)
  • 原文地址:https://www.cnblogs.com/lzj-0218/p/3526344.html
Copyright © 2011-2022 走看看