Topic 1105: Inverse Code for strings

Source: Internet
Author: User
Tags uppercase character

Title Description:

A binary number, each of which is reversed, called the number of the inverse code. Below we define a character's inverse code. If this is a lowercase character, then it is the same distance from the characters ' a ' as its inverse code and the character ' Z ', and if it is an uppercase character, it is the same distance from its inverse code as the character ' Z ', and if it is not in both cases, its counter code is itself.

For example, ' A ' 's inverse code is ' z '; ' C ' 's anti-code is ' x '; ' W ' 's anti-code is ' D '; ' 1 ' is the inverse of ' 1 '; ' $ ' is the inverse code or ' $ '.
The inverse code of a string is defined as the inverse of all its characters. Our task is to calculate the inverse code for a given string.

Input:

The input each line is a string, and the string length is no more than 80 characters. If the input is only!, indicates the end of the input and does not require processing.

Output:

For each string entered, output its inverse code, one row for each data.

Sample input:
Hello jlu-ccst-2011!
Sample output:
Svool qof-xxhg-2011

This problem must be read in by Get (), or presentation Error
1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <algorithm>5#include <cmath>6 #defineMAX 1027  8 CharTodeal[max];9 intMainintargcChar Const*argv[])Ten { One     intN, M, K; A     //freopen ("Input.txt", "R", stdin); - gets (todeal); -      while(strcmp (Todeal,"!") !=0) { the         for(inti =0; I < strlen (todeal); i++) { -           if(Todeal[i] >='a'&& Todeal[i] <='Z') { -printf"%c",'a'+'Z'-todeal[i]); -           } +           Else if(Todeal[i] >='A'&& Todeal[i] <='Z') { -printf"%c",'A'+'Z'-todeal[i]); +           } A           Else { atprintf"%c", Todeal[i]); -           } -        } -Puts""); - gets (todeal); -     } in     return 0; -}

Topic 1105: Inverse Code for strings

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.