U E D R , A S I H C RSS

문자반대출력/문보창

면 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;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:29
Processing time 0.0094 sec