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

#include <iostream>
#include <cctype>

#define SIZE 100+1

using namespace std;

void decryptRot13Cipher(char *str);

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

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