首页 > 代码库 > 查找“asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafd” 该字符串中有多少个af

查找“asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafd” 该字符串中有多少个af

#include <stdio.h>
#include <string.h>

void main()
{
char str[] = "asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafa";
int i = 0,num = 0;
for(i = 0; i < strlen(str) - 1; i++)
{
if(str[i] == ‘a‘ && str[i + 1] == ‘f‘)
{
num++;
}
}

printf("找到%d个af\n",num);

}

查找“asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafd” 该字符串中有多少个af