河北工业大学c语言考试题,求C语言大神,,,,急求,,,,

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

大神解释一下各个部分的功能,,,

#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;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值