我是靠谱客的博主 开放电源,这篇文章主要介绍字符串b在字符串a中出现的次数,现在分享给大家,希望可以做个参考。

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

int main()
{
	string aa,bb;
	cin >> aa>>bb;
	char *a, *search;
	a = &aa[0];
	search = &bb[0];

	char *b = NULL;
	int count(0);
	while (*a != '')
	{
		a = strstr(a, search);//返回字符出现的第一个位置
		if (a != NULL)
		{
			count++;
			a = a + strlen(search);
		}
		else
		{
			break;

		}
	} 
	printf("出现的次数:%dn", count);
	system("pause");
	return 0;
}

 

最后

以上就是开放电源最近收集整理的关于字符串b在字符串a中出现的次数的全部内容,更多相关字符串b在字符串a中出现内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(126)

评论列表共有 0 条评论

立即
投稿
返回
顶部