版本比较
2048
正文
增加 20 行删除 3 行
2 行未改动34567789101187 行未改动9910010110210310310410510610744 行未改动15215315415515615715815916016116216316416516616716816917085 行未改动2562572582592492602612622632645 行未改动2702712722732742752762772782792802812822832 行未改动#include<windows.h>#include<conio.h>using namespace std;int a[5][5]={0},b[5][5]={0};int t[10]={2,2,2,2,2,4,2,2,2,2};int t[11]={2,4,8,16,32,64,128,256,512,1024,2048};int m=0,op=0,ffff=0;struct node{int x=0,y=0;};int f(int x){ if(x==0)return 1;87 行未改动 if(!move) return true; return false;}void spawn_block(){ int x=t[rand()%10]; int x=t[rand()%11]; int popopo=0; node p[20]; for(int i=1;i<=4;i++) for(int j=1;j<=4;j++)44 行未改动 cout<<" C++ 2048 控制台版\n W S A D 控制方向\n 按y开始游戏"; char xxx=_getch(); while(xxx!='y'&&xxx!='Y') xxx=_getch(); again: system("cls"); int f; cout<<" 1.正常模式 2.开挂模式 (默认为2)"; cin>>f; if(f==1){ t[0]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=2; t[10]=4; }else{ t[1]=2; for(int i=1;i<=10;i++)t[i]=t[i-1]*2; } memset(a,0,sizeof(a)); m=0,op=0,ffff=0; spawn_block(); spawn_block();85 行未改动 for(int i=1;i<=4;i++)for(int j=1;j<=4;j++)if(old_board[i][j]!=a[i][j])moved=true; if(moved) spawn_block(); system("cls"); print_board(); if(check_gameover()){ if(check_gameover()&&m!=2048){ ffff=1; MessageBox(NULL,"游戏失败,格子已满无法移动","2048",MB_OK); } }5 行未改动 if(cccc=='y'||cccc=='Y') goto again; else exit(0); }else{ MessageBox(NULL,"恭喜!合成2048,游戏胜利!","2048",MB_OK); system("cls"); cout<<"是否重新开始?(y/n)"; char cccc=_getch(); while(cccc!='n'&&cccc!='N'&&cccc!='y'&&cccc!='Y') cccc=_getch(); if(cccc=='y'||cccc=='Y') goto again; else exit(0); } return 0;}```