//这是源程序,中文是乱码,不好意思,将就看吧
#include <stdio.h>
#include <malloc.h>
#include "stdlib.h"
#include "string.h"
#define maxsize 100
int k[10];
void index(char *a,char *b)
{
k[0]=-1;
int i,j,m,n;
i=0;j=0;m=0;n=0;
while(a[i]!='\0')
{
if(a[i]==b[j])
{
++i;++j;
}
else
{
i=i-j+1;j=0;
}
if(b[j]=='\0')
{
n=i-j;
k[m]=n;
k[m+1]=-1;
++m;
}
}
}
void main()
{
int o;
char s[maxsize];
char p[maxsize];
char t[maxsize];
printf("\n");
printf("\n");
printf(" µÚËÄÕ ×Ö·û´®µÄÆ¥ÅäÓëÌæ»» \n");
printf("\n");
printf("\n");
printf(" by Ç¿²¨ ѧºÅ:06040648 \n");
printf(" \n");
printf(" 2006.3\n");
printf("\n");
printf("********************************************************************************\n");
printf("ÇëÊäÈëÔʼ×Ö·û´®.\n");
scanf("%d",&o);
gets(s);
printf("ÇëÊäÈëÒª²éÕÒµÄ×Ö·û´®P.\n");
gets(p);
printf("ÄãÏëÒª°Ñ×Ö·û´®%sÌ滻Ϊʲô?.\n",p);
gets(t);
printf("\n");
printf("*************************\n");
index(s,p);
char x[100];
int e=0,f=0,g=0,h=0,i=0,j=0,l=0;
f=strlen(p);
g=strlen(t);
strcpy(x,s);
if(k[0]!=-1)
{
i=k[e];
for(;k[e]!=-1;)
{
strcpy(&s[i],t);
i=i+g;
h=k[e]+f;
strcpy(&s[i],&x[h]);
e++;
i=k[e]+(g-f)*e;
}
printf("Ìæ»»Íê³É,ÕâÀïÊÇÊäÈë½á¹û:\n");
printf("%s\n",s);
}
else
{
printf("¶Ô²»Æð,ûÓÐÆ¥Åä×Ö·û´®,Ôʼ×Ö·û´®Ã»ÓиĶ¯\n");
printf("%s\n",s);}
printf("Í˳öÇë°´1,ÆäËûÈÎÒâ¼ü¼ÌÐø\n");
scanf("%d",&o);
if(o==1)
{
exit(1);
}
else
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
main();
}