"Huawei OJ" string encryption and decryption

Source: Internet
Author: User
Tags printf time limit
Describe:

Title Description

1, the input string is added and decrypted, and output.

2 Encryption methods are:

When the content is an English letter is replaced with the letter of the latter letter, while the letter conversion case, such as the letter A is replaced by B, the letter z is replaced by A;

When the content is a number, the number is added 1, such as 0 to replace the replacement 2,9 replacement 0;

Other characters do not change.

3, the decryption method is the inverse process of encryption.

Interface Description:

Implement interfaces, each of which implements 1 basic operations:

void Encrypt (char aucpassword[], char aucresult[]): Implements string encryption in this function and outputs

Description

1. The string ends with a.

2, string maximum 100 characters.

int Unencrypt (char result[], char password[]): Implement string decryption and output in this function

Description

1. The string ends with a.

2, string maximum 100 characters.

Knowledge Points: String
Source of the topic: Internal finishing
Practice Stage: Primary
Run time limit: 10Sec
Memory Limit: 128MByte
Input:

Enter a description
Enter a string of passwords to encrypt
Enter a string of password encryption

Output:

Output description
Output encrypted characters
Output decrypted characters

Sample input:
ABCDEFG
BCDEFGH

                   
Sample output:
BCDEFGH
ABCDEFG

   


#include "stdio.h"
#include "string.h"
#include "ctype.h"
Void Change (char str[])
{
	int l=0, i=0, j=0;
	L = strlen (str);
	for (i = 0; i < l; i++)
	{
	if (Isupper (Str[i]))
	str[i] = (Str[i] + 32-1-' a ' + +)% 26+ ' a ';
	else if (Islower (Str[i]))
	str[i] = (Str[i]-+ 1-' a ' + +)% + ' a ';
	else if (IsDigit (Str[i]))
	str[i] = (Str[i] + 1-' 0 ' + Ten)% + ' 0 ';

	}
	for (i = 0; i < l; i++)
	{
		printf ("%c", Str[i]);
	}
	printf ("\ n");
}
int main ()
{
	char str1[1000],str2[1000];
	Gets (STR1);
	Gets (STR2);
	Change (STR1);
	Change (STR2);
	return 0;

}















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.