diff --git a/src/funktion.c b/src/funktion.c index c0047ba..fcd45fa 100644 --- a/src/funktion.c +++ b/src/funktion.c @@ -248,3 +248,9 @@ float vPunkt(float x1, float x2, float x3, float z1, float z2, float z3, float p } return result; } +double probability_from_tree(double successful_outcomes, double total_outcomes, double branches) { + double result; + result = successful_outcomes / (total_outcomes * branches); + printf("The probability is: %lf\n", result); + return result; +} diff --git a/src/funktion.h b/src/funktion.h index 80c9c75..b2c9872 100644 --- a/src/funktion.h +++ b/src/funktion.h @@ -41,5 +41,6 @@ float Vmiddle3(float x3, float z3); float Vskalort(float x1, float x2, float x3, float z1, float z2, float z3); 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); #endif diff --git a/src/main.c b/src/main.c index 31959f4..ad9f810 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ int main() { - double a,b,c,d,h,x1,s1,x2,x3,z1,z2,z3,p1,p2,p3,m; + double a,b,c,d,h,x1,s1,x2,x3,z1,z2,z3,p1,p2,p3,m,x,y,z; a = getValue('a'); b = getValue('b'); h = getValue('h'); @@ -195,4 +195,10 @@ int main() p2 = getValue('P'); p3 = getValue('P'); vPunkt(x1,x2,x3,z1,z2,z3,p1,p2,p3); + + printf("Enter the number of successful outcomes, total outcomes, and number of branches: "); + x = getValue('S'); + y = getValue('T'); + z = getValue('B'); + probability_from_tree(x, y, z); }