#include <stdio.h>
#include <ctype.h>  // isalpha(), islower(), isupper()

// 시저 암호화 함수
void caesar_cipher(char* str, int shift) {
    while (*str != '\0') {
        // 'i'를 '!'로 바꿔주는 조건 추가
        if (*str == 'i') {
            *str = '!';  // 'i'를 '!'로 변환
        }
        // 대문자인 경우
        else if (isupper(*str)) {
            *str = ((*str - 'A' + shift) % 26 + 26) % 26 + 'A'; // A-Z 범위 내에서 이동
        }
        // 소문자인 경우
        else if (islower(*str)) {
            *str = ((*str - 'a' + shift) % 26 + 26) % 26 + 'a'; // a-z 범위 내에서 이동
        }
        str++;  // 다음 문자로 이동
    }
}

int main() {
    char input[100];
    int shift;

    // 사용자로부터 문자열 입력 받기
    printf("Enter a string: ");
    fgets(input, sizeof(input), stdin);

    // 사용자로부터 이동값(shift) 입력 받기
    printf("Enter shift value: ");
    scanf("%d", &shift);

    // 시저 암호 적용 및 'i'를 '!'로 바꾸기
    caesar_cipher(input, shift);

    // 결과 출력
    printf("Encrypted string: %s\n", input);

    return 0;
}
