《面向对象程序设计》(8)

时间:2025-04-19

renew(chessboard,cursor.x,cursor.y); break; case 80: // 下 cursor.x++; if(cursor.x>14) cursor.x=14; renew(chessboard,cursor.x-1,cursor.y); renew(chessboard,cursor.x,cursor.y); break; case 75: // 左 cursor.y--; if(cursor.y<0) cursor.y=0; renew(chessboard,cursor.x,cursor.y+1); renew(chessboard,cursor.x,cursor.y); break; case 77: // 右 cursor.y++; if(cursor.y>14) cursor.y=14; renew(chessboard,cursor.x,cursor.y-1); renew(chessboard,cursor.x,cursor.y); break; case 134: // 退出 quit=true; return true; } else if(c==13 && chessboard[cursor.x][cursor.y].step==0) return true; // 下子 else if(c=='U' || c=='u'){ // 悔棋 regret=true; return true; } } }

void beback(NODE chessboard[][15], int step) {//悔棋 int i,j,tempx,tempy; if(step==1) return; // 如果才开始,直接返回 if(step>2){ // 如果下了多于两步 for(i=0;i<15;i++) // 搜索前两步所下的位置 for(j=0;j<15;j++) { if(chessboard[i][j].step==step-1){ // 找到上一步 chessboard[i][j].step=0; // 清空棋子标志 renew(chessboard,i,j);} // 重绘棋盘 else if(chessboard[i][j].step==step-2){ // 找到上两步 chessboard[i][j].step=0; // 清空棋子标志 tempx=cursor.x; // 记录光标位置 tempy=cursor.y; cursor.x=i; // 将光标回复到

《面向对象程序设计》(8).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219