U E D R , A S I H C RSS

압축알고리즘/태훈,휘동

RLE

~cpp 
#include <iostream>
#include <fstream>
using namespace std;
void main()
{
	ifstream fin("input.txt"); //형식은 3b11a같이
	char ch;
	int num;
	do{
		fin >> num;	// 포인트...
		fin.get(ch);
		for ( int i = 0 ; i < num ; i++ )
			cout << ch;

	}while( !fin.eof() );
}

DPCM

압축


~cpp 
#include <iostream>
using namespace std;
void main()
{
	char ch;
	ch = cin.get();
	cout << ch;
	char initial = ch;
	do {
		cout << initial - ch;
		cin.get(initial);
	}while(!(initial == '\n'));

}

~cpp 
#include <iostream>
using namespace std;
void main()
{
	char ch;
	ch = cin.get();
	cout << ch;
	char initial = ch;
	do {
		cout << initial - ch;
		cin.get(initial);
		if((initial-ch>9||initial-ch<-9))
		{
			ch = initial;
			cout << ch;
		}
	}while(!(initial == '\n'));

}

축알고리즘
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:23
Processing time 0.0101 sec