1 #include<iostream>
2 #include<string>
3 #include<fstream>
4 #include<algorithm>
5 #include<time.h>
6 using namespace std;
7
8 string replace(string s)
9 {
10 replace(s.begin(),s.end(),0,0);
11 return s;
12 }
13
14 int main()
15 {
16 string* sp;
17 int x;
18
19
20 ifstream inf("stage3.txt");
21 ofstream outf("Decrypted.txt");
22 inf >> x;
23 inf.ignore();
24 sp=new string[x];
25 time_t rawtime;
26 struct tm* timeinfo;
27 time(&rawtime);
28 timeinfo=localtime(&rawtime);
29
30 for(int i=0; i<x; ++i)
31 {
32 string s;
33 getline(inf,s);
34 sp[i]=replace(s);
35
36 if(sp[i].find("Decrypt stage 1 complete")!=string::npos)
37 sp[i]="Decrypted by j";
38 if(sp[i].find("Decrypt stage 2 complete")!=string::npos)
39 sp[i]=asctime(timeinfo);
40
41 cout<< sp[i] <<endl;
42 }
43
44 for(int i=0; i<x; ++i)
45 {
46 outf<< sp[i]<<endl;
47 }
48 sp=NULL;
49 delete []sp;
50 }
코딩 여기까지 했는데 위에 replace 함수로 불러온 텍스트에 단어 몇개 바꿔야 되는데 어떻게 하지 ㅠㅠㅠ
Replace “barn” with “Galactica”
Replace “toaster” with “Cylon”
Replace “juice” with “fuel”
Replace “wagon” with “viper”
Replace “stage 1” with the current time
Replace “stage 2” with “FRAKKEN”
문자열의 위치를 찾고, 지우고, 삽입한다.
그 문자열 찾는걸 못하겟음 ㅠㅠ
c++좀 갖다버려라.