该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
大神解释一下各个部分的功能,,,
#include
#include
#include
#include
using namespace std;
const int SIZ = 20 ;
char out[SIZ+1][SIZ+1] ;
int ac , wr;
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
void print()
{
for (int i = 0 ; i < SIZ ; i++)
{
for (int j = 0 ; j < SIZ ; j++)
{
cout << out[i][j] << " " ;
}
cout << endl;
}
double temp1 = ac+wr ;
double temp2 = ac ;
cout << "您打对了" << ac+wr << "中的" << ac << "个,正确率为" ;
if (temp1==0)
{
cout << 0 << endl;
}
else
{
if(temp1==temp2)
{
cout << "100%" << endl;
}
else
{
cout << setprecision(2) << temp2/temp1*100 << "%" << endl;
}
}
}
bool catchit(char check)
{
char get;
if(_kbhit())
{
get = _getch();
if(get==check)
{
ac++;
}
else
{
if(get==27)//ESC
{
exit(1);
}
wr++;
}
return true;
}
return false ;
}
void godown(int x , int y)
{
print();
sleep(1000);
system("cls");
while(x
{
out[x+1][y] = out[x][y] ;
out[x][y] = ' ';
x++;
print();
sleep(1000);
system("cls");
if(catchit(out[x][y]))
{
memset(out,0,sizeof(out));
print();
sleep(1000);
system("cls");
return;
}
}
wr++;
}
int main()
{
int temp ,tempx ,tempy;
memset(out,0,sizeof(out));
ac = 0 ;
wr = 0 ;
while (1)
{
srand(time(0)) ; //以当前时间做种子
temp = rand()%90+33 ;
tempx = rand()%SIZ;
tempy = rand()%SIZ;
out[tempx][tempy] = temp ;
godown(tempx , tempy);
}
return 0;
}