/*
Nome: Mario
Cognome: Montanari
Classe: 3AIN
Data: 08/03/2025
*/

#include <iostream>
#include <cctype>

#define SIZE 100+1

using namespace std;

void decryptAtbashCipher(char *str);

int main(void) {
	char str[SIZE]; //ABCDEFGHIJKLMNOPQRSTUVWXYZ
	
	cout << "Inserisci una frase: ";
	cin.getline(str, SIZE);
	
	decryptAtbashCipher(str);
	
	return 0;
}

void decryptAtbashCipher(char *str) {
	int j = 0;
	
	for (int i = 0; str[i] != '\0'; i++) {
		if (!isalpha(str[i])) {
			str[j++] = str[i];
		} else {
			if (isupper(str[i])) {
				str[j++] = 'Z' - (str[i] - 'A');
			} else if (islower(str[i])) {
				str[j++] = 'z' - (str[i] - 'a');
			}
		}
	}
	
	str[j] = '\0';
	
	cout << "Frase decodificata:  " << str << endl;
}