Pagini recente » Cod sursa (job #1478110) | Cod sursa (job #2369921) | Cod sursa (job #2906838) | Cod sursa (job #34030)
Cod sursa(job #34030)
#include<fstream.h>
int main(){
ifstream fin("cifre.in");
ofstream fout("cifre.out");
long int a,b,x,p=1;
double z=0;
short c,k=0,nr=0,s=0;
fin>>a>>b>>c>>k;
while (s<k-1) {
s++;
p*=10;}
for (long int i=p;i<=b;i++){
x=i;
nr=0;
for (;x!=0;x/=10)
if (x%10==c)
nr++;
if (nr>=k)
z++;}
if (z!=0){
long int h=b-a+1;
z/=h;
fout<<int(z);
if (int(z)!=0){
z*=10000;
fout<<"."<<int(z);}}
else
fout<<0;
fin.close();
fout.close();
return 0;
}