如何加强企业网站建设 论文百度优化大师
描述
给定一个非负整数a,求其中含有数字b的个数(0<=a<2147483647,0<=b<=9)。
如100001中含所有0的个数为4,1的个数为2。
输入
输入数据有多组,每组一行,每行为两个整数,即a和b,以EOF结束。
输出
每组输出一个整数,即a中含有数字b的个数。
样例输入
100001 0
100001 1
样例输出
4
2
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
int x,y,n,m,num;
while(scanf("%d %d",&x,&y)!=EOF){
n=x;
num=0;
if(n==0&&y==0)num++;
while(n){
m=n%10;
n=n/10;
if(m==y)num++;
}
printf("%d\n",num);
}
return 0;
}