Cod sursa(job #75079)

Utilizator Mihai1990Brudasca Mihai Mihai1990 Data 30 iulie 2007 15:43:58
Problema Cifre Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include<fstream.h>
#include<math.h>
long int a,b;
int c,k,cont,contor=0;
int function(long int x)
{
if(x==0&&c==0&&k==1)
  return 1;
  else;
int r;
cont=0;
while(x!=0)
  {
  r=x%10;
  if(r==c)
	cont++;
  if(cont==k)
	x=0;
	else x/=10;
  }
if(cont==k)
  return 1;
  else return 0;
}
int main()
{
float val;
ifstream fin("cifre.in");
ofstream fout("cifre.out");
fin>>a>>b>>c>>k;
int i;
for(i=pow(10,k-1);i<=b;i++)
   if(function(i)==1)
	 contor++;
val=float(contor)/float((b-a+1));
fout<<val;
return 0;
}