Topic BackgroundBackground a konjac Konjac fan on the "small book", one day when the login forgot password (He did not bind the mailbox or cell phone), so he threw the question to God Ben you.
Title Description DescriptionKonjac Konjac Although he forgot his password, he remembered that the password was made up of a string of letters. And the password is formed by a string of letters each moving backwards N. He now finds the string of letters and n before moving, please ask for your password.
input/output format input/output
Input Format:
First line: N. Second line: A string of letters before it is moved
output Format:
A line that is the password for this konjac Konjac
input and Output sample sample Input/output
sample Test point # #
Input Sample:
1
Qwe
Sample output:
Rxf
Idea: This problem is simple, just move the letter back a few on it, note that the question is to take the number of bits, if greater than Z or greater than Z, modulo 26.
Remember, not minus 26, but modulo, this takes into account if you want to move 100 or more cases, otherwise you will have 40 points (do not ask me why I know, because you know ^_^), but also to consider the case of casing!
The code is as follows:
#include <stdio.h>#include<string.h>intMain () {Chara[ -]; intN,i; scanf ("%d",&N); scanf ("%s", a); for(i=0; I<strlen (a); i++) { if(a[i]>='A'&&a[i]<='Z')//Uppercase{A[i]= ((a[i]- $+n)% -)+ $;//take the mold, +65 } Else //lowercase{A[i]= ((a[i]- the+n)% -)+ the; }} puts (a); return 0; }
Rokua-Small book--password-simple string