Problem Description
Given a word, use the Caesar password to encrypt the word.
The Caesar cipher is a technique for replacing encryption. All letters in a word are shifted back by 3 digits in the alphabet and then replaced with cipher text. That is, a becomes d, b becomes e, ..., w becomes z, x becomes a, y becomes b, and z becomes c.
For example, lanqiao will become odqtldr.
Input format
Enter a line containing one word, and the word contains only lowercase English letters.
Output format
A line is output, indicating the encrypted ciphertext.
Sample input
lanqiao
Sample output
odqtldr
Evaluation use case size and agreement
For all evaluation use cases, the number of letters in a word does not exceed 100.
analysis
Now that we have said "only lowercase letters", we don't consider the case of uppercase letters and other non-word characters.
Use \ (0 ~ 25 instead of a ~ z \) , then \ ((number + 3) \% 26 \) , and then +97 to output.
answer
#include <string.h>
int main()
{
char a[101],len,i;
scanf("%s",a);
len=strlen(a);
for(i=0;i<len;i++)
{
a[i]=(a[i]-97+3)%26+97;
}
printf("%s",a);
return 0;
}