如何加強企業(yè)網(wǎng)站建設(shè) 論文企業(yè)網(wǎng)站注冊域名的步驟
描述
給定一個非負(fù)整數(shù)a,求其中含有數(shù)字b的個數(shù)(0<=a<2147483647,0<=b<=9)。
如100001中含所有0的個數(shù)為4,1的個數(shù)為2。
輸入
輸入數(shù)據(jù)有多組,每組一行,每行為兩個整數(shù),即a和b,以EOF結(jié)束。
輸出
每組輸出一個整數(shù),即a中含有數(shù)字b的個數(shù)。
樣例輸入
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;
}