Question 7th: simple password cracking (acm)

Source: Internet
Author: User

Print? Description
Password is a very important thing in our life. We rely on it for all the secrets we can't tell. Wow, haha.
Next, yuanzi needs to add a password on the password, which is simple but safe.
Assume that the original BBS password of yuanzi is zvbo941987. To make it easier to remember, yuanzi uses an algorithm to convert the password to YUANzi1987. This password is his name and year of birth, I cannot forget it, and I can put it in a conspicuous place without being known by others.
He is changing like this. Everyone knows the letters on the phone: 1--1, abc -- 2, def -- 3, ghi -- 4, jkl -- 5, mno -- 6, pqrs -- 7, tuv -- 8 wxyz -- 9, 0--0, is so simple. yuanzi converts the lowercase letters in the password into corresponding numbers, and does not change the numbers or other symbols. The statement is as follows: there are no spaces in the password, and the uppercase letters in the password are converted to lowercase letters, and then moved back one character. For example, X is first converted to lowercase letters, and then moved back one character, it's not just y. It's easy. Remember, moving z back is.
Input
The input includes multiple test data. The input is in plain text. The password cannot exceed 100 characters and is entered until the end of the file.
Output
Output the real ciphertext of the child.

Description
Password is a very important thing in our life. We rely on it for all the secrets we can't tell. Wow, haha.
Next, yuanzi needs to add a password on the password, which is simple but safe.
Assume that the original BBS password of yuanzi is zvbo941987. To make it easier to remember, yuanzi uses an algorithm to convert the password to YUANzi1987. This password is his name and year of birth, I cannot forget it, and I can put it in a conspicuous place without being known by others.
He is changing like this. Everyone knows the letters on the phone: 1--1, abc -- 2, def -- 3, ghi -- 4, jkl -- 5, mno -- 6, pqrs -- 7, tuv -- 8 wxyz -- 9, 0--0, is so simple. yuanzi converts the lowercase letters in the password into corresponding numbers, and does not change the numbers or other symbols. The statement is as follows: there are no spaces in the password, and the uppercase letters in the password are converted to lowercase letters, and then moved back one character. For example, X is first converted to lowercase letters, and then moved back one character, it's not just y. It's easy. Remember, moving z back is.
Input
The input includes multiple test data. The input is in plain text. The password cannot exceed 100 characters and is entered until the end of the file.
Output
Output the real ciphertext of the child.

 

[Plain]
# Include <stdio. h>
# Include <string. h>

Int main ()
{
Int n, I;
Char t;
Char a [101];
While (gets ()! = NULL)
{
N = strlen ();
 
For (I = 0; I <n; I ++)
{
If (a [I]> = 'A' & A [I] <= 'y ')
{
A [I] = a [I] + 32 + 1;
}
Else if (a [I] = 'Z ')
{
A [I] = 'a ';
}
Else if (a [I]> = 'A' & a [I] <= 'Z ')
{
T = a [I];
Switch (t)
{
Case 'A': case 'B': case 'C': a [I] = '2 ';
Break;
Case 'D': case 'E': case 'F': a [I] = '3 ';
Break;
Case 'H': case 'I': case 'G': a [I] = '4 ';
Break;
Case 'K': case 'l': case 'J': a [I] = '5 ';
Break;
Case 'M': case 'N': case 'O': a [I] = '6 ';
Break;
Case 'p': case 'q': case 'r': case 's': a [I] = '7 ';
Break;
Case 'T': case 'U': case 'V': a [I] = '8 ';
Break;
Case 'W': case 'X': case 'y': case 'Z': a [I] = '9 ';
Break;

}
}
}
Puts (a); // output Password
}
Return 0;
}

# Include <stdio. h>
# Include <string. h>

Int main ()
{
Int n, I;
Char t;
Char a [101];
While (gets ()! = NULL)
{
N = strlen ();

For (I = 0; I <n; I ++)
{
If (a [I]> = 'A' & A [I] <= 'y ')
{
A [I] = a [I] + 32 + 1;
}
Else if (a [I] = 'Z ')
{
A [I] = 'a ';
}
Else if (a [I]> = 'A' & a [I] <= 'Z ')
{
T = a [I];
Switch (t)
{
Case 'A': case 'B': case 'C': a [I] = '2 ';
Break;
Case 'D': case 'E': case 'F': a [I] = '3 ';
Break;
Case 'H': case 'I': case 'G': a [I] = '4 ';
Break;
Case 'K': case 'l': case 'J': a [I] = '5 ';
Break;
Case 'M': case 'N': case 'O': a [I] = '6 ';
Break;
Case 'p': case 'q': case 'r': case 's': a [I] = '7 ';
Break;
Case 'T': case 'U': case 'V': a [I] = '8 ';
Break;
Case 'W': case 'X': case 'y': case 'Z': a [I] = '9 ';
Break;

}
}
}
Puts (a); // output Password
}
Return 0;
}

 

 

Related Article

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.