All pastes #2106304 Raw Edit

Miscellany

public c v1 · immutable
#2106304 ·published 2012-01-26 08:06 UTC
rendered paste body
// playgame.c// Author:  Kevin Okal// Date:    01/25/12// Purpose: Plays a simple guessing game.#include "playcgame.h"#include "cgame.h"#include <stdio.h>int guess_count, initial_size, half_guess, high, low, new_guess, new_guess_high;int autoguess(int current_guess){   guess_count = guess_count + 1;   new_guess = low + ((high - low) / 2);      if (guess(current_guess) == 'r')   {      return guess_count;   }      else if (guess(current_guess) == 'l')   {      low = current_guess;//      printf("%d, %d, %d, %d, %d\n",guess_count, current_guess, new_guess, high, low);      return autoguess(new_guess);   }      else       high = current_guess; //     printf("%d, %d, %d, %d, %d\n",guess_count, current_guess, new_guess, high, low);      return autoguess(new_guess);}                  int playgame(int n){//   initial_size = n;   guess_count = 0;   high = n;   low = 0;   startgame(n);   return autoguess(new_guess);}