#include<iostream>
#include<string.h>
using namspace std;
//以下压缩连续的字符
void del(char *s,int len)
{
int i=0,j=0;
char *p=s;
cout<<"len="<<len<<endl;
while(*p)
{
while(*p==*(p+1))
for(char *q=p;*q;q++)
{*q=*(q+1);q[--len]=='\0';}
p++;
}
puts(s);
}
int main()
{
char s[100];
int len=0;
cout<<"input a string"<<endl;
gets(s);
len=strlen(s);
del(s,len);
return 0;
}
压缩字符串
最新推荐文章于 2023-06-11 19:41:05 发布