그래서 ROT13decoder를 만들려고 노력 중이며, 지금까지 내가 가지고있는 것입니다. 글자 중 일부만 변경되며 이유는 확실하지 않습니다. 나는 프로그래밍에 초보 다. 나는 파일을 읽고 파일을 쓰는 방법을 알아 내려고 노력하고있다. 지금까지는 그 부분이 작동하지만 네, 원본 파일의 모든 문자를 변경하지는 않으며 그 중 일부는 변경되지 않습니다. 나는 어떤 의견이라도 정말로 바르게 평가할 것이다.내 프로그램이 일부 문자 만 변경하는 이유
#include <iostream>
#include <fstream>
//the letters in the secretMessage file are "Lbh unir gb fgnl va funcr. Zl tenaqzbgure, fur fgnegrq jnyxvat svir zvyrf n qnl jura fur jnf 60. Fur’f 97 gbqnl naq jr qba’g xabj jurer gur uryy fur vf
//
//
//and this is what it outputs to the decodedMessage file "Lbh haie gb fgal ia fhace. Ml geaadmbghee, fhe fgaeged jalkiag fiie milef a dal jhea fhe jaf 60. Fhe’f 97 gbdal aad je dba’g kabj jheee ghe hell fhe if.
using namespace std;
int main(){
ofstream fout;
ifstream fin;
fin.open("secretMessage.txt");
fout.open("decodedMessage.txt");
char c = 0;
while (!fin.eof()){
c = fin.get();
if (c == 'a')c = 'n';
if (c == 'b')c = 'o';
if (c == 'c')c = 'p';
if (c == 'd')c = 'q';
if (c == 'e')c = 'r';
if (c == 'f')c = 's';
if (c == 'g')c = 't';
if (c == 'h')c = 'u';
if (c == 'i')c = 'v';
if (c == 'j')c = 'w';
if (c == 'k')c = 'x';
if (c == 'l')c = 'y';
if (c == 'm')c = 'z';
if (c == 'n')c = 'a';
if (c == 'o')c = 'b';
if (c == 'p')c = 'c';
if (c == 'q')c = 'd';
if (c == 'r')c = 'e';
if (c == 's')c = 'f';
if (c == 't')c = 'g';
if (c == 'u')c = 'h';
if (c == 'v')c = 'i';
if (c == 'w')c = 'j';
if (c == 'x')c = 'k';
if (c == 'y')c = 'l';
if (c == 'z')c = 'm';
if (c == 'A')c = 'N';
if (c == 'B')c = 'O';
if (c == 'C')c = 'P';
if (c == 'D')c = 'Q';
if (c == 'E')c = 'R';
if (c == 'F')c = 'S';
if (c == 'G')c = 'T';
if (c == 'H')c = 'U';
if (c == 'I')c = 'V';
if (c == 'J')c = 'W';
if (c == 'K')c = 'X';
if (c == 'L')c = 'Y';
if (c == 'M')c = 'Z';
if (c == 'N')c = 'A';
if (c == 'O')c = 'B';
if (c == 'P')c = 'C';
if (c == 'Q')c = 'D';
if (c == 'R')c = 'E';
if (c == 'S')c = 'F';
if (c == 'T')c = 'G';
if (c == 'U')c = 'H';
if (c == 'V')c = 'I';
if (c == 'W')c = 'J';
if (c == 'X')c = 'K';
if (c == 'Y')c = 'L';
if (c == 'Z')c = 'M';
cout << c;
if (!fin.eof())fout << c;
}
fin.close();
fout.close();
return 0;
}