Scissors Small Game C language

Source: Internet
Author: User

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 (&AMP;T1);
    Time (&AMP;T2);
while ((T2-T1) <n) time (&AMP;T2); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.