I wrote this simple encryption code where First, each uppercase, or lowercase letter must be shifted three positions to the right, according to the ASCII table: letter 'a' should become letter 'd', letter 'y' must become the character '|' and so on. Second, each line must be reversed. After being reversed, all characters from the half on (truncated) must be moved one position to the left in ASCII. In this case, 'b' becomes 'a', and 'a' becomes '`'
My code is here:
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
char s[10000],b[10000];
int a,i,len,j,c,decre,divition,x;
scanf("%d",&a);
for(i=1;i<=a;i++)
{
len=0;
c=0;
decre=0;
for(x=0;x<1000;x++)
{
s[i]='\0';
b[i]='\0';
}
scanf(" %[^\n]s",s);
len=strlen(s);
//printf("%d",len);
for(j=0;j<len;j++)
{
if((b[j] >= 'a' && b[j] <= 'z') || (b[j] >= 'A' && b[j] <= 'Z')||(b[j]>=123&&b[j]<=126))
{
c=s[j];
s[j]=c+3;
}
}
for(j=len-1;j>=0;j--)
{
b[decre]=s[j];
decre++;
//printf("%d\n",j);
}
divition=len/2;
for(j=divition;j<len;j++)
{
if((b[j] >= 'a' && b[j] <= 'z') || (b[j] >= 'A' && b[j] <= 'Z')||(b[j]>=123&&b[j]<=126)||(b[j]>=33&&b[j]<=47)||(b[j]>=91&&b[j]<=96))
{
c=b[j];
b[j]=c-1;
}
}
printf("%s\n",b);
}
}
So if i input such a it will output c.
Input:
4
Texto #3
abcABC1
vxpdylY .ph
vv.xwfxo.fd
Output:
3# rvzgV
1FECedc
ks. \n{frzx
gi.r{hyz-xx
My output:
3# oswdS
4FECbaS
hp.#Yn{crzu
Gi1rxhvw-xx