¶
만 문 면 process_wchar() 를 부린. ( 는 만, 리는 )를 들보. "" 는 문 ver1 램 뒤면 "" 머 는 "ㅏㅏ" . 면 문를 문 뒤 ""는 문 "ㅏㅏ" 만들 놓는면 ver1 를 바 , process_wchar()만 는 능 모 .
ver1 ( 문 ) ¶
~cpp #include <fstream> #include <algorithm> #include <string> using namespace std; string read_file(); void write_file(const string & str); void main() { string str = read_file(); reverse(str.begin(), str.end()); // 문 는 STL write_file(str); } // 부 문 들. string read_file() { string str; fstream fin("source.txt"); char ch = fin.get(); while (ch != EOF) { str += ch; ch = fin.get(); } return str; } // 문 . void write_file(const string & str) { fstream fout("result.txt"); fout << str; }
ver2 (문 대 ) ¶
~cpp #include <fstream> #include <algorithm> #include <string> using namespace std; string read_file(); void write_file(const string & str); void process_wchar(string & str); void main() { string str = read_file(); process_wchar(str); reverse(str.begin(), str.end()); // 문 는 STL write_file(str); } // 문를 리 void process_wchar(string & str) { // str[i]는 char. 만 문 부면 . for (int i = 0; i < str.length(); i++) { if (str[i] < 0 && str[i + 1] < 0) { swap(str[i], str[i+1]); i++; } } } // 부 문 들. string read_file() { string str; fstream fin("source.txt"); char ch = fin.get(); while (ch != EOF) { str += ch; ch = fin.get(); } return str; } // 문 . void write_file(const string & str) { fstream fout("result.txt"); fout << str; }