1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
#include <cstdlib>
using namespace std;
int tab[10]={2,2,3,2,2,7,8,6,5,4};
int l=0;
int ile_dziel(int start, int stop, int n)
{
if (start==stop) return tab[start];
int p=(start+stop)/2;
int i1=ile_dziel(start,p, n);
int i2=ile_dziel(p+1,stop, n);
if (i1==n) l++;
if (i2==n) l++;
return l;
}
int main()
{
int n;
cout << ile_dziel(0,4,2);
system("pause");
return 0;
}
| |