Pagini recente » Cod sursa (job #665452) | Cod sursa (job #1942622) | Cod sursa (job #2885310) | Cod sursa (job #2693394) | Cod sursa (job #498795)
Cod sursa(job #498795)
#include<conio.h>
#include<fstream.h>
int cifra(int x,int c)
{int k=0;
while(x)
{if(x%10==c)k++;
x/=10;
}
return k;
}
void main()
{clrscr();
int c,k,i,nr=0,aux;
long a,b;
double p;
ifstream f("c:\\TC\\idate.txt");
ofstream g("c:\\TC\\odate.txt");
f>>a;
f>>b;
f>>c;
f>>k;
if(a>b){aux=a;
a=b;
b=aux;
}
for(i=a;i<=b;i++)
if(cifra(i,c)>=k)nr++;
p=(double)nr/(b-a+1);
g<<p;
getch();
}