Soon to graduate, recently a period of time has been looking at some of the basics of C language. Plan to share some of the latest gains from today. Let's write a program about string compression today.
Simply put, a string such as "Aaaaabcccddde", written as "A5b1c3d3e1". The code is as follows
void Yasu (char *s)
{
char *p;
Char reschar[100];//holds the compressed string
memset (reschar,null,sizeof (Reschar));//string assignment is null
p=s;
int count=1;
int k=0;
int Len=strlen (s);
for (int i=0;i<=len-1;i++)
{
if (P[i+1]==p[i])
{
count++
}
else
{
//sprintf (Reschar+strlen (Reschar), "%c%d", p[i],count);
if ((count>=10) && (count<100))
{
int d1=count%10;
int d2= (COUNT/10)%10;
reschar[k++]=d2+ ' 0 ';
reschar[k++]=d1+ ' 0 ';
}
else
{
reschar[k++]=count+ ' 0 ';
}
Itoa (count,reschar[k++],10);
Count=1
}
}
printf ("%s\n", Reschar);
}
If you have any questions, please ask.