8610. Previous and next letter

 

A letter of the English alphabet is given. Print its previous and next letter.

 

Input. One letter ñ (Ac <Z’ or ac < z) of the English alphabet (lowercase or uppercase).

 

Output. Print the letter that precedes c, followed by the letter that comes after c in the English alphabet (preserving the case).

 

Sample input 1

Sample output 1

D

C E

 

 

Sample input 2

Sample output 2

X

w y

 

 

SOLUTIONS

chars

 

Algorithm analysis

Let c be the input character. Print the characters c – 1 and c + 1.

 

Algorithm realization

Read the input symbol c.

 

scanf("%c", &c);

 

Print the symbols c – 1 and c + 1.

 

printf("%c %c\n", c - 1, c + 1);

 

Python realization

Read the input symbol c.

 

c = input()

 

Compute and print the symbols prev = c – 1 and next = c + 1.

 

prev = chr(ord(c) - 1)

next = chr(ord(c) + 1)

print(prev, next)