Small game with C language (2)-Scissors
# Include <stdio. h> void menu () {printf ("************** welcome to the stone scissors cloth game ************* \ n "); printf ("********************* 1. start> ********************* \ n "); printf ("********************* 0. exit> ********************* \ n "); printf ("************************************* * ********* \ n ");} int main () {int input = 1; char ch [10]; int n = 0; int B = 0; int I = 0; int j = 0; int k = 0; int a = 0; while (input) {menu (); printf ("SELECT>"); scanf ("% d", & input ); switch (input) {case 1: {for (I = 0; I <3; I ++) {srand (unsigned int) time (NULL )); n = rand () % 3; printf ("extract stone-Scissors-cloth \ n"); scanf ("% s", ch); if (strcmp (ch, "Stone") = 0) B = 0; else if (strcmp (ch, "Scissors") = 0) B = 1; else if (strcmp (ch, "cloth") = 0) B = 2; if (B = n) {printf ("Draw \ n"); k ++ ;} else if (B = 0) & (n = 1) {printf ("Congratulations, you have won \ n"); j ++ ;} else if (B = 0) & (n = 2) {printf ("Sorry you lost \ n"); a ++ ;} else if (B = 1) & (n = 0) {printf ("Sorry you lost \ n"); a ++ ;} else if (B = 1) & (n = 2) {printf ("Congratulations, you have won \ n"); j ++ ;} else if (B = 2) & (n = 0) {printf ("Congratulations, you have won \ n"); j ++ ;} else {printf ("Sorry you lost \ n"); a ++;} if (j = 2) {break;} if (a = 2) {break ;}}if (j = 2) {printf ("Congratulations, you have won \ n"); break;} else if (a = 2) {printf ("Sorry you lost \ n"); break;} else if (k = 3) {printf ("this is a draw \ n "); break;} else if (k = 2) & (a = 1) {printf ("Sorry you lost in this game \ n "); break;} else if (k = 2) & (j = 1) {printf ("Congratulations, you have won \ n"); break ;} default: {printf ("exit GAME \ n"); system ("pause"); exit (0); break ;}} system ("pause "); return 0 ;}