题目要求:在不能使用已有字符串库函数条件下,返求出从字符串str中sFind子字符串出现的次数,如果str中不包含sFind则结果为0。
我编的:
#include<stdio.h>
#include<math.h>
int main()
{
int a = 0, b, c = 0, d = 0;
char str[32], sFind[32];
int i, j,k;
printf("please put str\n");
gets(str);
printf("please put sFind\n");
gets(sFind);
for (b = 0; b < 32; b++)
{
a = 0;
if (str[b] == sFind[a])
{
c = b;
while (sFind[a] == str[c])
{
if (sFind[a] == '\0')
{
d = d + 1;
break;
}
a = a + 1;
c = c + 1;
}
}
}
printf("%d", d);
return 0;
}
程序可以执行但的不到想要的结果0.0
还有一个问题,我用F10调试的时候不小心把哪个窗口关了,本来应该每点一下F10就显示一下各个变量的值现在那个窗口没了,应该在视图选项里把哪个重新打开一下?
alt+3没反应0.0
本回答被提问者采纳