Cod sursa(job #58995)
Utilizator | Bivol Mihai mihai0110 | Data | 7 mai 2007 21:20:33 |
---|---|---|---|
Problema | Cifre | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include<fstream.h>
ifstream f("cifre.in");
ofstream g("cifre.out");
unsigned long n=0,nr=0,a,b,i,nrc,y,x,k,c,aux,m;
double nrf;
int main()
{
f>>a>>b>>k>>c;
if (a>b)
{aux=a;
a=b;
b=aux;
}
n=b-a+1;
for (i=a;i<=b;i++)
{x=i;
nrc=0;
while(x>0)
{y=x%10;
x=x/10;
if (y==c)
nrc++;
}
if (nrc>=k)
nr++;
}
nrf=(double)nr/n;
m=nrf*10000;
nrf=(double)m/10000;
g<<nrf<<'\n';
f.close();
g.close();
return 0;
}