Blog moved, and recently updated at the same time, maybe when they completely moved away-_-
Http://blog.just666.cn This is the new blog address, I hope we can take care of
Written in C language Scissors games.
Source code Download address: http://www.oschina.net/code/snippet_2309129_45545
Name: Scissors game V1.0//Author: mouse,//time: 2015.1.19/////////////////////////////////#include <time.h> #include <iostream> #include <stdlib.h> #include <conio.h> #define SEC 1 using Namespac
e std;
function declaration int computer ();
char player ();
void Putui ();
void judge (int play, int com);
void TheEND ();
void out (int x);
void Wait (int n);
int win=0,lose=0,draw=0;
int main () {System ("title Scissors Game V1.0");
int play,com; while (1) {Putui (); Show UI play = player (); Player chooses wait (SEC); Set up wait com = computer (); Computer Selection judge (play,com); Judge TheEND ();
Freeze screen} return 0;
the int computer ()//Computer randomly generates an option {srand (unsigned) time (NULL));
Return to Rand ()%3+1;
Char player ()/wait for the player to select an option {int play;
cout<< "\t\t\t\t Please choose";
for (;;)
{play = Getch ();
if (play>= ' 1 ' &&play<= ' 3 ') return play-' 0 '; } void Putui ()//ui Output {System ("CLS");
System ("Color 0A");
cout<< "\t\t\t\t scissors game v1.0\n";
cout<< "Win:" <<win<< "\nlose:" <<lose<< "\ndraw:" <<draw<< "\ n";
cout<< "\t\t\t\t1, I am out of stone";
cout<< "\t\t\t\t2, I out scissors \ n";
cout<< "\t\t\t\t3, I out of cloth \ n";
} void judge (int play, int com)//Judge win/lose {if = = cout<< "\n\t\t\t you all Out";
Out (play);
cout<< "so make a tie!"
draw++;
else if play = 1 && com = 3 | |
Play = = 2 && com = 1 | |
Play = = 3 && com = 2) {cout<< "\n\t\t\t you Out";
Out (play);
cout<< ", the computer out";
Out (COM); cout<< ", you lost.
\ n ";
lose++;
else {cout<< "\n\t\t\t you Out";
Out (play);
cout<< ", the computer out";
Out (COM); cout<< ", you win.
";
win++; }
}
void TheEND ()//Screen freeze {getch ();}
void out (int x)///According to the numerical value of what is {if (x = = 1) cout<< "stone";
if (x = = 2) cout<< "scissors";
if (x = = 3) cout<< "cloth";
} void Wait (int n)//set waiting {int i; cout<< "\n\t\t\t .....
Please wait....\n ";
time_t t1,t2;
Time (&T1);
Time (&T2);
while ((T2-T1) <n) time (&T2); }