

這是我的代碼,測驗用例能過,但是保密過不了,有沒有大佬幫忙看看哪里出了問題,還有這道題怎么做,謝謝啦
#include <stdio.h>
int main()
{
char s[100],t[10],str[10],a[120];
int count1,count2,count3;
int n,i,j,x;
for(i=0;i<100;i++)
{
scanf("%c",&s[i]);
if(s[i]=='\n')
{
break;
}
}count1=i;//陣列s[]元素個數 count1
for(i=0;i<10;i++)
{
scanf("%c",&t[i]);
if(t[i]=='\n')
{
break;
}
}count2=i;//陣列t[]元素個數count2
for(i=0;i<10;i++)
{
scanf("%c",&str[i]);
if(str[i]=='\n')
{
break;
}
}count3=i; //陣列str[]元素個數count3
int w=-1;
h: w++; //回到原來位置
for(i=w;i<100;i++)
{
if(s[i]==t[0])//下標為i相等
{
break;
}
}int p=0;
for(j=i;j<100;j++)
{
if(s[j]==t[p])//下標為j不等
{
p++;
}else
{
break;
}
}
if(j-i==count2)//判斷是否為被替換字串
{
for(n=0;n<i;n++)
{
a[n]=s[n];
}
for(n=i;n<count3+i;n++,x++)
{
a[n]=str[x];
}
for(n=count3+i;n<count1-count2+count3;n++,j++)
{
a[n]=s[j];
}
if(count1-count2+count3<=100)
{
for(n=0;n<count1-count2+count3;n++)
{
printf("%c",a[n]);
}
printf("\n");
}else
{
for(n=0;n<100;n++)
{
printf("%c",a[n]);
}
printf("\n");
}
}else
{
goto h;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/236264.html
標籤:C語言
下一篇:未加載libTUIO.pdb
