More actions
imported>Unknown No edit summary |
(Repair batch-0006 pages from live compare) |
||
| Line 13: | Line 13: | ||
string pass; | string pass; | ||
fin >> pass; | fin >> pass; | ||
for(int i = 0;pass | for(int i = 0;pass[i];i++) | ||
{ | { | ||
if(pass | if(pass[i] != temp) | ||
{ | { | ||
if(i!=0) | if(i!=0) | ||
fout << number << temp; | fout << number << temp; | ||
temp = pass | temp = pass[i]; | ||
number = 1; | number = 1; | ||
} | } | ||
| Line 43: | Line 43: | ||
string pass; | string pass; | ||
fin >> pass; | fin >> pass; | ||
for(int i = 0;pass | for(int i = 0;pass[i];i++) | ||
{ | { | ||
if(i==0) | if(i==0) | ||
temp = pass | temp = pass[i]; | ||
else | else | ||
{ | { | ||
pass | pass[i] = (temp-pass[i])+48; | ||
if(pass | if(pass[i] < 48 ) | ||
{ | { | ||
number = pass | number = pass[i] - 48; | ||
fout << number; | fout << number; | ||
continue; | continue; | ||
} | } | ||
} | } | ||
fout << pass | fout << pass[i]; | ||
} | } | ||
| Line 73: | Line 73: | ||
int decimal; | int decimal; | ||
int num; | int num; | ||
char pass | char pass[20]; | ||
fin >> pass; | fin >> pass; | ||
int length = strlen(pass); | int length = strlen(pass); | ||
for(int i = (length-1); i < 0; i--) | for(int i = (length-1); i < 0; i--) | ||
{ | { | ||
if(isalpha(pass | if(isalpha(pass[i])) | ||
{ | { | ||
decimal = 1; | decimal = 1; | ||
num = (pass | num = (pass[i] - 48) * decimal; | ||
decimal *= 10; | decimal *= 10; | ||
else | else | ||
| Line 102: | Line 102: | ||
string pass; | string pass; | ||
fin >> pass; | fin >> pass; | ||
for(int i = 0;pass | for(int i = 0;pass[i];i++) | ||
{ | { | ||
if(i==0) | if(i==0) | ||
temp = pass | temp = pass[i]; | ||
else | else | ||
{ | { | ||
if(pass | if(pass[i] == 45) | ||
{ | { | ||
i++; | i++; | ||
pass | pass[i] = temp+(pass[i]-48); | ||
} | } | ||
else | else | ||
pass | pass[i] = temp-(pass[i]-48); | ||
} | } | ||
fout << pass | fout << pass[i]; | ||
} | } | ||
} | } | ||
Latest revision as of 01:08, 27 March 2026
압축1
#include<fstream>
#include<iostream>
#include<string>
using namespace std;
void main()
{
ifstream fin("input.txt");
ofstream fout("output.txt");
char temp = NULL;
int number = 0;
string pass;
fin >> pass;
for(int i = 0;pass[i];i++)
{
if(pass[i] != temp)
{
if(i!=0)
fout << number << temp;
temp = pass[i];
number = 1;
}
else
{
number ++;
}
}
fout << number << temp;
}
압축2
#include<fstream>
#include<iostream>
#include<string>
using namespace std;
void main()
{
ifstream fin("input.txt");
ofstream fout("output.txt");
char temp = NULL;
int number;
string pass;
fin >> pass;
for(int i = 0;pass[i];i++)
{
if(i==0)
temp = pass[i];
else
{
pass[i] = (temp-pass[i])+48;
if(pass[i] < 48 )
{
number = pass[i] - 48;
fout << number;
continue;
}
}
fout << pass[i];
}
}
해제1
#include<fstream>
#include<iostream>
#include<string>
using namespace std;
void main()
{
ifstream fin("output.txt");
ofstream fout("input.txt");
int decimal;
int num;
char pass[20];
fin >> pass;
int length = strlen(pass);
for(int i = (length-1); i < 0; i--)
{
if(isalpha(pass[i]))
{
decimal = 1;
num = (pass[i] - 48) * decimal;
decimal *= 10;
else
dacimal
}
해제2
#include<fstream>
#include<iostream>
#include<string>
using namespace std;
void main()
{
ifstream fin("output.txt");
ofstream fout("input.txt");
char temp = NULL;
string pass;
fin >> pass;
for(int i = 0;pass[i];i++)
{
if(i==0)
temp = pass[i];
else
{
if(pass[i] == 45)
{
i++;
pass[i] = temp+(pass[i]-48);
}
else
pass[i] = temp-(pass[i]-48);
}
fout << pass[i];
}
}