U E D R , A S I H C RSS

문자반대출력/조현태

C++

느낀


러브데 다..OTL
되게 만들다.^^
봤는데.. 본 보기만..^^ 남 보기~~( 를 못배다..ㅠ.ㅜ 2기가 되 데..ㅠ.ㅜ)
그래 교로 봐길..ㅎㅎ


#include <iostream>
#include <fstream>

const bool TRUE=1;
const bool FALSE=0;

using namespace std;

class stack
{
private:
	char *data_p;
	int where_is_save;
	int max_size_of_stack;
public:
	stack( int data_size )
	{
		data_p=(char*)malloc(data_size*sizeof(char));
		max_size_of_stack=data_size;
		where_is_save=0;
	}
	~stack()
	{
		free(data_p);
	}
	bool get_in(char save_data)
	{
		if (where_is_save != max_size_of_stack)
		{
			*(data_p+where_is_save)=save_data;
			++where_is_save;
			return TRUE;
		}
		else
			return FALSE;
	}
	bool get_out(char *where_save_p )
	{
		if (where_is_save)
		{
			--where_is_save;
			*where_save_p=*(data_p+where_is_save);
			return TRUE;
		}
		return FALSE;
	}
	void clear_data()
	{
		where_is_save=0;
	}
};

int main()
{
	// 다.
	ifstream inputFile("source.txt");
	if(!inputFile)
	{
		cout << "   다.\n";
		return 0;
	}
	inputFile.seekg(0,ios_base::end);
	stack file_data(inputFile.tellg());
	inputFile.seekg(0);
	char temp;
	// 기록다.
	while (inputFile.get(temp))
	{
		file_data.get_in(temp);
	}
	inputFile.close();
	ofstream outputFile("result.txt");
	if (outputFile == 0 )
	{
		cout << "   다.\n";
		return 0;
	}
	//기록  다.
	while (file_data.get_out(&temp))
	{
		if (0>temp)
		{
			char temp_next;
			file_data.get_out(&temp_next);
			outputFile << temp_next << temp;
		}
		else
			outputFile << temp;
	}
	outputFile.close();
	return 0;
}

Erlang

느낀

닌데 몰라 30 맸다 -_ -;
C++ 뭔가 다 -_ -;;;
민망 -_ -;;

18> lists:reverse("Hello. CAUCSE!!").
"!!ESCUAC .olleH"

Erlang - 2

느낀

무 날로 먹 reverse다 -_ -ㅎ

  • pr_3.erl

-module(pr_3).
-export([reverse/1]).
reverse([]) -> [];
reverse([First|Remain]) -> reverse(Remain) ++ [First].

  • shell

23> c(pr_3).             
{ok,pr_3}
24> pr_3:reverse("Hello. CAUCSE!!").
"!!ESCUAC .olleH"

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:30
Processing time 0.0107 sec