void evaluate_hand(int Decks[2][5][2], int Hands[2], const char *hNames[]) { int i; for( i = 0; i < 2; i++) { if ((check_flush(Decks, i)) && (check_straight(Decks, i))) { Hands[i] = 9; continue; } else if (check_four(Decks, i)) { Hands[i] = 8; continue; } else if (check_full(Decks, i)) { Hands[i] = 7; continue; } else if (check_flush(Decks, i)) { Hands[i] = 6; continue; } else if (check_straight(Decks, i)) { Hands[i] = 5; continue; } else if (check_three(Decks, i)) { Hands[i] = 4; continue; } else if (check_two_pair(Decks, i)) { Hands[i] = 3; continue; } else if (check_pair(Decks, i)) { Hands[i] = 2; continue; } else Hands[i] = 1; } if (Hands[0] > Hands[1]) printf("HAND 1 WINNER with %s\n ", hNames[Hands[0]-1]); else if (Hands[1] > Hands[0]) printf("HAND 2 WINNER with %s\n", hNames[Hands[1]-1]); else if (getMax(Decks, 0) > getMax(Decks, 1)) printf("HAND 1 WINNER with %s\n ", hNames[Hands[0]-1]); else if (getMax(Decks, 1) > getMax(Decks, 0)) printf("HAND 2 WINNER with %s\n", hNames[Hands[1]-1]); else printf("Split\n"); }
int main (void) { gsl_ieee_env_setup (); { double t[N]; int n; const double zeta_2 = M_PI * M_PI / 6.0; /* terms for zeta(2) */ for (n = 0; n < N; n++) { double np1 = n + 1.0; t[n] = 1.0 / (np1 * np1); } check_trunc (t, zeta_2, "zeta(2)"); check_full (t, zeta_2, "zeta(2)"); } { double t[N]; double x, y; int n; /* terms for exp(10.0) */ x = 10.0; y = exp(x); t[0] = 1.0; for (n = 1; n < N; n++) { t[n] = t[n - 1] * (x / n); } check_trunc (t, y, "exp(10)"); check_full (t, y, "exp(10)"); } { double t[N]; double x, y; int n; /* terms for exp(-10.0) */ x = -10.0; y = exp(x); t[0] = 1.0; for (n = 1; n < N; n++) { t[n] = t[n - 1] * (x / n); } check_trunc (t, y, "exp(-10)"); check_full (t, y, "exp(-10)"); } { double t[N]; double x, y; int n; /* terms for -log(1-x) */ x = 0.5; y = -log(1-x); t[0] = x; for (n = 1; n < N; n++) { t[n] = t[n - 1] * (x * n) / (n + 1.0); } check_trunc (t, y, "-log(1/2)"); check_full (t, y, "-log(1/2)"); } { double t[N]; double x, y; int n; /* terms for -log(1-x) */ x = -1.0; y = -log(1-x); t[0] = x; for (n = 1; n < N; n++) { t[n] = t[n - 1] * (x * n) / (n + 1.0); } check_trunc (t, y, "-log(2)"); check_full (t, y, "-log(2)"); } { double t[N]; int n; double result = 0.192594048773; /* terms for an alternating asymptotic series */ t[0] = 3.0 / (M_PI * M_PI); for (n = 1; n < N; n++) { t[n] = -t[n - 1] * (4.0 * (n + 1.0) - 1.0) / (M_PI * M_PI); } check_trunc (t, result, "asymptotic series"); check_full (t, result, "asymptotic series"); } { double t[N]; int n; /* Euler's gamma from GNU Calc (precision = 32) */ double result = 0.5772156649015328606065120900824; /* terms for Euler's gamma */ t[0] = 1.0; for (n = 1; n < N; n++) { t[n] = 1/(n+1.0) + log(n/(n+1.0)); } check_trunc (t, result, "Euler's constant"); check_full (t, result, "Euler's constant"); } { double t[N]; int n; /* eta(1/2) = sum_{k=1}^{\infty} (-1)^(k+1) / sqrt(k) From Levin, Intern. J. Computer Math. B3:371--388, 1973. I=(1-sqrt(2))zeta(1/2) =(2/sqrt(pi))*integ(1/(exp(x^2)+1),x,0,inf) */ double result = 0.6048986434216305; /* approx */ /* terms for eta(1/2) */ for (n = 0; n < N; n++) { t[n] = (n%2 ? -1 : 1) * 1.0 /sqrt(n + 1.0); } check_trunc (t, result, "eta(1/2)"); check_full (t, result, "eta(1/2)"); } { double t[N]; int n; double result = 1.23; for (n = 0; n < N; n++) { t[n] = (n == 0) ? 1.23 : 0.0; } check_trunc (t, result, "1.23 + 0 + 0 + 0..."); check_full (t, result, "1.23 + 0 + 0 + 0..."); } exit (gsl_test_summary ()); }