Please turn off the lights before you go to sleep version

Source: Internet
Author: User

#include "wz.h" #include "sts.h" #define   max  5void show (Int arr[][max]) { for ( int i=0;i<max;i++)  {  for (int j=0;j<max;j++)   {   cout <<arr[i][j]<<  " ";  }  cout<<endl; } cout<< Endl;} Void play (int arr[][max],int x,int y) { if (x < 0 | |  y < 0 | |  x >= max | |  y >= max)  {  return ; } arr[x][y] = 1 -arr[x][ Y]; if (x-1 >= 0)  {  arr[x-1][y] = 1 - arr[x-1][y]; }  if (X+1 < max)  {  arr[x+1][y] = 1 - arr[x+1][y]; }  if (y-1 >= 0)  {  arr[x][y-1] = 1 - arr[x][y-1]; }  if (Y+1 < max) &NBSP;{&NBSP;&NBSP;ARR[X][Y+1]&NBSP;=&NBSP;1&NBSP;-&NBSP;ARR[X][Y+1];&NBSP;}}&NBSP;&NBSP;VOID&NBSP;CP (Int v[][max],int k,int a[],int  b[]) {       int i;  for (i=k;i>0;i--)   {  play (V,a[i],b[i]); show (v);}   cout<< "Computer display complete   system has exited  " &LT;&LT;ENDL;  static  int  cc=1;int player () {          while (CC)       {        int a [100]={0};int b[100]={0}; int v[max][max] = {0}; int x,y;         int k=3,i=0;        int state= 1;        time_t t; srand ((unsigned) time (&t));         k=rand ()%5+1;      cout<< "sleep before lights out."    Welcome to section   "&LT;&LT;CC<< "  Off" <<endl;      cc++;while (i++<k) {        x=rand ()%5;    y=rand ()%5;     a[i]=x;b[i ]=y;      play (v,x,y);}  show (v);        while ( state)  {       cout<< "Sleep before lights out   Enter coordinates (x, y), (0,0) exit" <<endl;   cin>>x>>y;                   if (x==0&&y==0) cc=0;                  x=x-1;y=y-1;                 if (x>-1&&x<5&&y>-1&&y<5)         {    i++;   a[i]=x;b[i]=y;                 if (i++==100) {  cout<< "Computer display    player steps too many, system has exited  " <<endl;state=0;}      play (v,x,y);   show (v);                          }                       if (x+y>10) {&NBSP;CP (v,i+1,a,b); state=0;}  }        }}int main () {   cout<< "****** "<<endl;   cout<<"             Welcome to participate in the lighting game       <<endl<<                 provided by Wzzx "<<endl;   cout& Lt;< "    in the process of entering x+y greater than 10 can choose the computer demonstration solution steps   " <<endl;   cout<< "* "<<endl;   player ();  return 0;}

Please turn off the lights before you go to sleep version

Related Article

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.