diff --git a/src/funktion.c b/src/funktion.c index cace527..0be2aa9 100644 --- a/src/funktion.c +++ b/src/funktion.c @@ -282,4 +282,12 @@ int dezimal_to_bin(int dezimal) { } else { return (dezimal % 2 + 10 * dezimal_to_bin(dezimal / 2)); } -} \ No newline at end of file +} +int dezimal_binar_linksverschiebung(int dezimal) { + dezimal = dezimal * 2; + if (dezimal == 0) { + return 0; + } else { + return (dezimal % 2 + 10 * dezimal_to_bin(dezimal / 2)); + } + } \ No newline at end of file diff --git a/src/funktion.h b/src/funktion.h index 12affd7..571c3c3 100644 --- a/src/funktion.h +++ b/src/funktion.h @@ -45,5 +45,6 @@ double probability_from_tree(double successful_outcomes, double total_outcomes, int binomial_coefficient(int n, int k); int ByOne(int n); int dezimal_to_bin(int dezimal); +int dezimal_binar_linksverschiebung(int dezimal); #endif diff --git a/src/main.c b/src/main.c index f4057af..49e8116 100644 --- a/src/main.c +++ b/src/main.c @@ -211,4 +211,8 @@ int main() dezimal = getValue('X'); dezimal_to_bin(dezimal); + + printf("Geben sie eine Zahl ein: "); + dezimal = getValue('X'); + dezimal_binar_linksverschiebung(dezimal); }