Browse Source

add probability_from_tree

main
fdai6887 2 years ago
parent
commit
37569b69ed
  1. 6
      src/funktion.c
  2. 1
      src/funktion.h
  3. 8
      src/main.c

6
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;
}

1
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

8
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);
}
Loading…
Cancel
Save