Cod sursa(job #2051018)

Utilizator alex2kamebossPuscasu Alexandru alex2kameboss Data 28 octombrie 2017 14:01:54
Problema Cifre Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <iostream>
#include <cstdio>

using namespace std;
int a,b,c,k;
double rez;
bool cif(int x)
{
    int r=0;
    while(x!=0)
    {
        r+=(x%10==c);
        x/=10;
    }
    return r>=k;
}
int main()
{
    freopen("cifre.in","r",stdin);
    freopen("cifre.out","w",stdout);
    scanf("%d %d %d %d", &a,&b,&c,&k);
    for(int i=a;i<=b;i++)
    {
        rez+=cif(i);
    }
    printf("%.04f",rez/((b-a+1)*1.0));
    return 0;
}