Browse Source

add ByOne

main
Fdai7396 2 years ago
parent
commit
cd744a4da4
  1. 15
      src/funktion.c
  2. 1
      src/funktion.h
  3. 4
      src/main.c

15
src/funktion.c

@ -264,3 +264,18 @@ int binomial_coefficient(int n, int k) {
}
return result;
}
int ByOne(int n) {
int orig, count = 0;
orig = n;
while (n > 0) {
n = n >> 1 << 1;
if (orig - n == 1)
count++;
orig = n >> 1;
n = orig;
}
orig = count;
n = count;
printf("Das Ergebnis lautet: %d", n);
return count;
}

1
src/funktion.h

@ -43,5 +43,6 @@ double Vangle(float x1, float x2, float x3, float z1, float z2, float z3);
float vPunkt(float x1, float x2, float x3, float z1, float z2, float z3, float p1, float p2, float p3);
double probability_from_tree(double successful_outcomes, double total_outcomes, double branches);
int binomial_coefficient(int n, int k);
int ByOne(int n);
#endif

4
src/main.c

@ -7,6 +7,7 @@
int main()
{
double a,b,c,d,h,x1,s1,x2,x3,z1,z2,z3,p1,p2,p3,m,x,y,z;
int n;
a = getValue('a');
b = getValue('b');
h = getValue('h');
@ -204,4 +205,7 @@ int main()
a = getValue('a');
b = getValue('b')
binomial_coefficient(a, b);
n = getValue('X');
ByOne(n);
}
Loading…
Cancel
Save