영어로 문장을쓰면 그 문장이 암호화되서 나옴 ㅋ
예를 들어서 "Hello World!" 를 입력하면 "Uryyb Jbeyq!"가 나옴 ㅋ
지금 씨를 배우고 있는중이라 아직은 이런 기본밖에 할줄 몰르네요 ㅋㅋ avr도 막 입문한 상태라 ㅋㅋ
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#define MAX_PHRASE_LENGTH 100
void EncodePhrase(char *original, char *encoded);
char EncodeCharacter(char c);
int main(void)
{
char phrase[MAX_PHRASE_LENGTH];
char encoded[MAX_PHRASE_LENGTH];
printf("Enter phrase to encode: ");
gets(phrase);
EncodePhrase(phrase, encoded);
printf("Encoded: %s\n\n", encoded);
return 0;
}
void EncodePhrase(char *original, char *encoded)
{
char c;
int i = 0;
/* use while loop to read through the original string and store the converted character into encoded array */
while (original[i] != '\0'){
c = original[i];
encoded[i] = EncodeCharacter(c);
i++;
/* add a NULL pointer at the end of the encoded string */
encoded[i] = '\0';
}
}
char EncodeCharacter(char c)
{
char character;
int value;
/* convert character into ascii code */
value = (int)c;
/* only change ascii value if it is alphabet */
if ((value >= 97) && (value <= 109)){
value+=13;
} else if ((value >= 110) && (value <= 122)){
value-=13;
} else if ((value >= 65) && (value <= 77)){
value+=13;
} else if ((value >= 78) && (value <= 90)){
value-=13;
}
/* convert ascii code into character */
character = (char)value;
/* return the encoded character */
return character;
}
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.