Δημοσιεύτηκε: 27 Ιουν 2011, 16:37
από stamatiou
migf1 έγραψε:#include <stdio.h>
#include <stdlib.h>
#include <time.h>

// -----------------------------------------------------------------------------
void game( void )
{
   int guess;
   int real = rand() % 100;

   printf("Please type a random number and then hit Enter:\n");
   fflush(stdin); scanf("%d", &guess);

   while (guess != real)
   {
      if (guess < real)
         printf("No it is bigger...\n");
      else
         printf("No it is less...\n");

      printf("Try again: ");
      fflush(stdin); scanf("%d", &guess);
   }

   return;
}

// -----------------------------------------------------------------------------
int main( void )
{
   char yes_no;

   srand( time(NULL) );
   do {
      game();
      printf("Well done!\nDo you want to play again (y/n)? ");
      fflush(stdin);
      scanf("%c", &yes_no);
   } while (  yes_no == 'y' );

   fflush(stdin); getchar();
   return 0;
}

Και πάλι όμως δεν δουλεύει το play again....