~cpp #include <fstream> #include <iostream> #include <stdlib.h> using namespace std; int main() { ifstream fin("input.txt"); // fin과 input.txt를 연결 ofstream fout("output.txt"); // fout과 output.txt를 연결 cout << "숫자 입력> "; int f; cin >> f; char a[20]; for (int i = 0; ; i++) { fin.getline(a,20); if (fin.eof()) break; int c = strlen(a); for (int d=0;d<c;d++) { cout << (char)(a[d]+f); fout << (char)(a[d]+f); } cout << endl; fout << endl; } cout << endl; return 0; }
~cpp #include <fstream> #include <iostream> #include <stdlib.h> using namespace std; int main() { ifstream fin("output.txt"); // fin과 input.txt를 연결 ofstream fout("output2.txt"); // fout과 output.txt를 연결 cout << "숫자 입력> "; int f; cin >> f; char a[20]; for (int i = 0; ; i++) { fin.getline(a,20); if (fin.eof()) break; int c = strlen(a); for (int d=0;d<c;d++) { cout << (char)(a[d]-f); fout << (char)(a[d]-f); } cout << endl; fout << endl; } cout << endl; return 0; }