No older revisions available
No older revisions available
DPCM 압축 ¶
~cpp
#include <iostream>
#include<string>
using namespace std;
int main()
{
string input;
cin >> input;
cout << input[0];
for(int i=0;i<input.size() ;i++)
{
cout << (int)(input[i] - input[0]);
}
}
DPCM 압축 업데이트 ¶
~cpp
#include <iostream>
#include<string>
using namespace std;
int main()
{
string input;
cin >> input;
cout << input[0];
char standard = input[0];
for(int i=0;i<input.size() ;i++)
{
if((int)(input[i] - standard)<10)
cout << (int)(input[i] - standard);
else
{
standard = input[i];
cout << standard;
cout << (int)(input[i] - standard);
}
}
}
DPCM 해제 ¶
~cpp
#include <iostream>
#include<string>
using namespace std;
int main()
{
string input;
cin >> input;
for(int i=1;i<input.size();i++)
{
cout << (char)(input[0] + (input[i] - '0'));
}
cout << endl;
}
DPCM 해제 업그레이드 ¶
~cpp
#include <iostream>
#include<string>
using namespace std;
int main()
{
string input;
cin >> input;
char standard = input[0];
for(int i=1;i<input.size();i++)
{
if(input[i]>='0' && input[i]<='9')
cout << (char)(standard + (input[i] - '0'));
else
{
standard = input[i];
cout<<(char)standard;
//cout << (char)(standard + (input[i] - '0'));
}
}
cout << endl;
}