snake game Version-2 (using random number)
#include <stdio.h> #include <stdlib.h> #include <time.h> char comp_choice() { int i = 1 , num, gnum; srand(time( 0 )); num = rand() % 100 + 1 ; if (num < 33 ) { return 'w' ; } else if (num< 66 ) { return 'g' ; } else if (num< 100 ) { return 's' ; } } int snakegame( char you, char comp) { if (comp == you) { return 0 ; } if (comp == 'w' && you == 's' ) { return 1 ; } else if (comp == 's' && you == 'w' ) { return - 1 ; } if (comp == 'w' && yo...
Comments
Post a Comment