删除重复元素——蓝桥杯——新的长度

/*
为库设计新函数DelPack,删除输入字符串中所有的重复元素。不连续的重复元素也要删除。
  要求写成函数,函数内部使用指针操作。
样例输入
1223445667889
样例输出
13579
样例输入
else
样例输出
ls
数据规模和约定
  字符串数组最大长度为100。
*/
#if 1
#include <stdio.h>


void sc_cf(char *);
int you_xt(char,char *);
void sc(char,char *);


int main(void)
{
char str[100+1];
gets(str);
sc_cf(str);
puts(str);
return 0;
}


void sc(char c,char * s)
{
char * x = s;
do
{
if( * s != c )
{
* x ++ = * s ;
}
}
while( * s ++ != '\0');
}


int you_xt(char c,char * s)
{
while( * s != '\0' )
{
if( * s == c )
{
return 1;
}
s ++ ;
}
return 0;
}


void sc_cf(char * s)
{
while( * s != '\0' )
{
if( you_xt(* s,s + 1) )
{
sc(* s,s);
sc_cf(s + 1);
}
else
{
sc_cf(s + 1);
}
s ++;
}
}
#endif 
全部评论

相关推荐

牛客87317764...:最近没啥hc,做好心灰意冷的准备。另外,大概率只有字节给你面试,最好别作为处女面
实习简历求拷打
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务