Home > Back-end >  Visual studio using c to write simple Simon why run strange
Visual studio using c to write simple Simon why run strange

Time:09-26

# include "stdafx. H"
#include
#include
#include
#include
#include
using namespace std;

Void delay (int SEC)
{
Time_t strat_time cur_time;
Time (& amp; Strat_time);
Do
{
Time (& amp; Cur_time);
} while ((cur_time - strat_time) & lt; The SEC);
}


Int main ()
{
Char another_game='y'

Int correct=false;

Int sequence_length=0;
Time_t seed;
Int number;

Int counter=0;
Int time_taken=0;
Int now;

//begins with

Cout & lt; & lt; "\ n welcome to simple Simon, watch the Numbers, remember them!!! "& lt; & lt; Endl;
Delay (2);
Cout & lt; & lt; "Only a second!" & lt; & lt; Endl;
Delay (2);
Cout & lt; & lt; "Wrote them, the faster the more the better!" & lt; & lt; Endl;
Delay (2);
Cout & lt; & lt; "You ready, last come!" & lt; & lt; Endl;
Delay (2);
Cout & lt; & lt; "Press enter to start" & lt; & lt; Endl;
Cin & gt;> Another_game;
//main program
Do
{
Correct=true;
Counter=0;
Sequence_length=2;
Time_taken=clock ();

While (correct)
{
Sequence_length +=counter++ % 3==0;

Seed=time (NULL);
Now=clock ();

Srand ((unsigned int) seed);
For (int I=1; i Cout & lt; & lt; "" & lt; & lt; The rand () % 10;

Delay (1);

Cout & lt; & lt; "\ r";
For (int I=1; i <=sequence_length; I++)
Cout & lt; & lt; "";

If (counter==1)
Cout & lt; & lt; "\ n input the number which you write down now";
The else
Cout & lt; & lt; "\ r";

Srand ((unsigned int) seed);
For (int I=1; i <=sequence_length; I++)
{
Cin & gt;> Number;
If (number!=rand () % 10)
{
Correct=false;
break;
}
}
If (correct==true)
Cout & lt; & lt; "\ nCorrect!" ;
The else
Cout & lt; & lt; "\ nWrong!" ;
}
Cin. Sync ();

Cout & lt; & lt; "\ nDo you want to paly again (y/n)?" ;
Cin & gt;> Another_game;

} while (another_game=='y');
return 0;
}
Best can use visual studio 2015 debugged, find out the problem, thank you very much!
  • Related