Pagini recente » Cod sursa (job #2237052) | Cod sursa (job #547568) | Cod sursa (job #2681050) | Cod sursa (job #1134192) | Cod sursa (job #235887)
Cod sursa(job #235887)
#include<stdio.h>
#include<math.h>
int main(){
freopen("cifre.in","r",stdin);
freopen("cifre.out","w",stdout);
long a,b,c,k,nr=0,i,x,na,uc;
double pr;
scanf("%ld%ld%ld%ld",&a,&b,&c,&k);
for(i=a;i<=b;++i){
x=i;na=0;
while(x&&na<k){
uc=x%10;x/=10;
if(uc==c) na++;
}
if(na==c) nr++;
}
pr=(double)(nr)/(b-a+1);
printf("%0.4lf",pr);
return 0;
}