¶
한 확 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; }