Mirror of character in string

You are given a string A of length N consisting of only lowercase english letters.
You need to generate B of length N which meets the following criteria

– Each element of B is a lowercase english letter
– Each element of B is opposite of A.
– For example - if A is azbyc, then B is zaybx
Input Format
The first line of input will contain a single integer T, denoting the number of test cases.
Each test case consists of a single line - the string A
Output Format
For each test case, output on a new line the string B

image

Solution: Python 3

t = int(input())
for i in range(t):
S = input()
A = “”
c = 0
i= 0
while i <len(S):
c = (abs(ord(S[i])-122))+97
A=A + chr(c)
i = i+1

print(A)
2 Likes

Run time error its showing that S = input() is an expected indent block

Use proper indentation

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
string s,te="";
cin>>s;
for(int i=0;i<s.length();i++)
{
if(s[i]>=‘a’&&s[i]<=‘z’)
{
char d=s[i]-‘a’;
char m=‘z’-d;
te=te+m;
}
}
cout<<te<<endl;
}
return 0;
}