码迷,mamicode.com
首页 > 其他好文 > 详细

字符串-02. 删除字符串中的子串(20)

时间:2014-12-19 00:25:30      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:style   ar   io   color   sp   for   on   bs   ad   

#include <stdio.h>
#include <string.h>
int main()
{
  char s1[81]="",s2[81]="";
  gets(s1);
  gets(s2);
  int i,j,k,c=1;
  while(c)
  for(c=0,i=0;s1[i]!=0;i++)
  {
  if(s1[i]==s2[0])
  {
  for(j=i,k=0;s1[j]!=0&&s2[k]!=0;j++,k++)
      if(s1[j]!=s2[k])
             break;
      if(k==strlen(s2))
  {
    char s3[81]="";
    strcpy(s3,s1+j);
    memset(s1+i,0,sizeof(s1+i));
    strcat(s1,s3);
    c=1;
    }
     }
 }
  puts(s1);
return 0;
}

字符串-02. 删除字符串中的子串(20)

标签:style   ar   io   color   sp   for   on   bs   ad   

原文地址:http://www.cnblogs.com/xiao-mo/p/4172801.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!