#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'를 '!'로 변환
}
// 대문자인 경우
*str = ((*str - 'A' + shift) % 26 + 26) % 26 + 'A'; // A-Z 범위 내에서 이동
}
// 소문자인 경우
*str = ((*str - 'a' + shift) % 26 + 26) % 26 + 'a'; // a-z 범위 내에서 이동
}
str++; // 다음 문자로 이동
}
}
int main() {
char input[100];
int shift;
// 사용자로부터 문자열 입력 받기
fgets(input
, sizeof(input
), stdin
);
// 사용자로부터 이동값(shift) 입력 받기
printf("Enter shift value: ");
// 시저 암호 적용 및 'i'를 '!'로 바꾸기
caesar_cipher(input, shift);
// 결과 출력
printf("Encrypted string: %s\n", input
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxjdHlwZS5oPiAgLy8gaXNhbHBoYSgpLCBpc2xvd2VyKCksIGlzdXBwZXIoKQoKLy8g7Iuc7KCAIOyVlO2YuO2ZlCDtlajsiJgKdm9pZCBjYWVzYXJfY2lwaGVyKGNoYXIqIHN0ciwgaW50IHNoaWZ0KSB7CiAgICB3aGlsZSAoKnN0ciAhPSAnXDAnKSB7CiAgICAgICAgLy8gJ2kn66W8ICchJ+uhnCDrsJTqv5Tso7zripQg7KGw6rG0IOy2lOqwgAogICAgICAgIGlmICgqc3RyID09ICdpJykgewogICAgICAgICAgICAqc3RyID0gJyEnOyAgLy8gJ2kn66W8ICchJ+uhnCDrs4DtmZgKICAgICAgICB9CiAgICAgICAgLy8g64yA66y47J6Q7J24IOqyveyasAogICAgICAgIGVsc2UgaWYgKGlzdXBwZXIoKnN0cikpIHsKICAgICAgICAgICAgKnN0ciA9ICgoKnN0ciAtICdBJyArIHNoaWZ0KSAlIDI2ICsgMjYpICUgMjYgKyAnQSc7IC8vIEEtWiDrspTsnIQg64K07JeQ7IScIOydtOuPmQogICAgICAgIH0KICAgICAgICAvLyDshozrrLjsnpDsnbgg6rK97JqwCiAgICAgICAgZWxzZSBpZiAoaXNsb3dlcigqc3RyKSkgewogICAgICAgICAgICAqc3RyID0gKCgqc3RyIC0gJ2EnICsgc2hpZnQpICUgMjYgKyAyNikgJSAyNiArICdhJzsgLy8gYS16IOuylOychCDrgrTsl5DshJwg7J2064+ZCiAgICAgICAgfQogICAgICAgIHN0cisrOyAgLy8g64uk7J2MIOusuOyekOuhnCDsnbTrj5kKICAgIH0KfQoKaW50IG1haW4oKSB7CiAgICBjaGFyIGlucHV0WzEwMF07CiAgICBpbnQgc2hpZnQ7CgogICAgLy8g7IKs7Jqp7J6Q66Gc67aA7YSwIOusuOyekOyXtCDsnoXroKUg67Cb6riwCiAgICBwcmludGYoIkVudGVyIGEgc3RyaW5nOiAiKTsKICAgIGZnZXRzKGlucHV0LCBzaXplb2YoaW5wdXQpLCBzdGRpbik7CgogICAgLy8g7IKs7Jqp7J6Q66Gc67aA7YSwIOydtOuPmeqwkihzaGlmdCkg7J6F66ClIOuwm+q4sAogICAgcHJpbnRmKCJFbnRlciBzaGlmdCB2YWx1ZTogIik7CiAgICBzY2FuZigiJWQiLCAmc2hpZnQpOwoKICAgIC8vIOyLnOyggCDslZTtmLgg7KCB7JqpIOuwjyAnaSfrpbwgJyEn66GcIOuwlOq+uOq4sAogICAgY2Flc2FyX2NpcGhlcihpbnB1dCwgc2hpZnQpOwoKICAgIC8vIOqysOqzvCDstpzroKUKICAgIHByaW50ZigiRW5jcnlwdGVkIHN0cmluZzogJXNcbiIsIGlucHV0KTsKCiAgICByZXR1cm4gMDsKfQo=