UVa 458 the Decoder (Minimalist code!) )

Source: Internet
Author: User
Tags character set time limit

458-the Decoder

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem &problem=399

Write a complete program that would correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact Contain. The code key for this simple coding are a one for one character substitution based upon a single arithmetic manipulatio n of the printable portion of the ASCII character set.

Input and Output

For Example:with the input file that contains:

1JKJ ' PZ ' {ol ' {yhklthyr ' vm ' {ol ' Jvu{yvs ' kh{h ' jvywvyh{pvu5
1PIT ' pz ' h ' {yhklthyr ' vm ' {ol ' PU{LYUH{PVUHS '] i| Zpulzz ' Thjopul ' jvywvyh{pvu5
1KLJ ' pz ' {ol ' {yhklthyr ' vm ' {ol ' kpnp{hs ' lx|pwtlu{'

Your program should print:

*CDC is the trademark's control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*dec is the trademark of the Digital equipment Corporation.

Your program should accept all sets of characters ' use ' same encoding scheme and should print the actual message of Each set of characters.

Sample Input

1JKJ ' PZ ' {ol ' {yhklthyr ' vm ' {ol ' Jvu{yvs ' kh{h ' jvywvyh{pvu5
1PIT ' pz ' h ' {yhklthyr ' vm ' {ol ' PU{LYUH{PVUHS '] i| Zpulzz ' Thjopul ' jvywvyh{pvu5
1KLJ ' pz ' {ol ' {yhklthyr ' vm ' {ol ' kpnp{hs ' lx|pwtlu{'

Sample Output

*CDC is the trademark's control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*dec is the trademark of the Digital equipment Corporation.

The sample tells you to subtract 7.

Complete code:

/*0.026s*/
  
#include <cstdio>
  
int main (void)
{
    char ch;
    while (~ (ch = getchar ()))
        Putchar (ch = = ' \ n '?) ' \ n ': ch-7);
    return 0;
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.