Browse Source

add dezimal_to_bin

main
Fdai7396 2 years ago
parent
commit
e44343ad9c
  1. 7
      src/funktion.c
  2. 1
      src/funktion.h
  3. 6
      src/main.c

7
src/funktion.c

@ -275,4 +275,11 @@ int ByOne(int n) {
n = orig;
}
return count;
}
int dezimal_to_bin(int dezimal) {
if (dezimal == 0) {
return 0;
} else {
return (dezimal % 2 + 10 * dezimal_to_bin(dezimal / 2));
}
}

1
src/funktion.h

@ -44,5 +44,6 @@ float vPunkt(float x1, float x2, float x3, float z1, float z2, float z3, float p
double probability_from_tree(double successful_outcomes, double total_outcomes, double branches);
int binomial_coefficient(int n, int k);
int ByOne(int n);
int dezimal_to_bin(int dezimal);
#endif

6
src/main.c

@ -7,7 +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;
int n,dezimal;
a = getValue('a');
b = getValue('b');
h = getValue('h');
@ -208,4 +208,8 @@ int main()
n = getValue('X');
ByOne(n);
printf("Bitte geben sie eine Zahl ein!");
dezimal = getValue('X');
dezimal_to_bin(dezimal);
}
Loading…
Cancel
Save