Describe 압축알고리즘/슬이,진영 here.
~cpp 
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

void main()
{
	char input[20];
	cout <<"압축 대상을 입력하세요 :";
	cin >> input;
	int count=0;
	int output=0;
	char first = input[0];
	int index = 0;
	int temp =0;
	cout << first;
	while(input[index]!=NULL)
	{
		if(input[index]==first){
			output=0;
			cout << output;
		}
		else {
			cout << (int)(input[index] - first);
		}
		index++;
	}
	
	cout <<"압축을 해제 할께요 :";
	char input2[20];
	cin >> input2;
	char firch = input2[0];
	index = 1;
	while(input2[index] != NULL)
	{ 
		char c = input2[index];
		int x = atoi(&c);
		temp = (int)firch + x;
		cout << (char)temp;
		index++;
	}

	/*int count=1;
	int index =0;
	while(input[index]!=NULL)
	{
		if(input[index]==input[index+1])
			count++;
		else
		{
			cout<<count<<input[index];
			count =1;
		}
		index++;
	}

	cout <<"이제부터 해제합니다."<< endl;
	cin>> input;
	int i=0;
	while(input[i]!=NULL)
	{
		int n = atoi(&input[i]);
		char ch = input[i+1];
		i+=2;
		for(int i=0; i < n ; i++)
			cout << ch;
	}
	*/	
}
Retrieved from http://wiki.zeropage.org/wiki.php/압축알고리즘/슬이,진영
last modified 2021-02-07 05:30:23