Pagini recente » Cod sursa (job #2256049) | Cod sursa (job #1254228) | Cod sursa (job #1656341) | Cod sursa (job #456912) | Cod sursa (job #48816)
Cod sursa(job #48816)
#include <fstream.h>
#include <iomanip.h>
unsigned long int a, b;
short int c, k;
int Ver(int, int, int);
int main()
{
ifstream fin("cifre.in");
ofstream fout("cifre.out");
fin >> a >> b >> c >> k;
int fav = 0, pos = 0;
for (int i = a; i <= b; i++)
{
if (Ver(i, c, k))
{
fav++;
pos++;
}
else
pos++;
}
fout << setprecision(4) << (float)fav / pos;
fin.close();
fout.close();
return 0;
}
int Ver(int x, int y, int z)
{
int nr = 0;
while(x)
{
if (x %10 == y)
nr++;
x /= 10;
}
if (nr >= z)
return 1;
else return 0;
}