3、h>#include#includeconstintback=30;//const,限定变量不允许被改变,back表示背景颜色constintspeed[]={0,12,9,6,3,1};constintnumber[]={0,2,3,5,7,11,15};constintcol[]={11,15,12,12,13,13,14};intrank=1;intlevel=0;//0表示既不是向右也不是向左,1表示向左,2表示向右intkind;intpri_kind;//7大类,颜色标记,调用col[col_kind];intrevolve
4、=0;//旋转状态标记struct{intx;inty;}current,before;struct//定义一个结构体内容包括坐标,颜色,是否显示方块{intx;inty;intcolor;boolhaving;//布尔型变量作逻辑判断运算结果为真或为假,有方块为真,没有方块为假}board[15][25];struct{intvary_x[4];intvary_y[4];}vary[]={{{0,2,4,6},{0,0,0,0}},{{0,0,0,0},{0,-1,-2,-3}},{{0,2,2,0},{0,0,-1,-1}},{{0,-2,-2,-4},{0,0,-1,
5、-1}},{{0,0,2,2},{0,-1,-1,-2}},{{0,2,2,4},{0,0,-1,-1}},{{0,0,-2,-2},{0,-1,-1,-2}},{{0,0,2,4},{0,-1,0,0}},{{0,0,0,2},{0,-1,-2,-2}},{{0,0,-2,-4},{0,-1,-1,-1}},{{0,2,2,2},{0,0,-1,-2}},{{0,2,4,4},{0,0,0,-1}},{{0,-2,-2,-2},{0,0,-1,-2}},{{0,0,2,4},{0,-1,-1,-1}},{{0,0,0,-2},{0,-1,-2,-2}},{{0,2,4,2
6、},{0,0,0,-1}},{{0,-2,0,2},{0,-1,-1,-1}},{{0,0,-2,0},{0,-1,-1,-2}},};struct{intsum;intconnection_x[5];intconnection_y[5];}connection[]={{2,{-2,2},{0,1}},{1,{0},{0}},{2,{2,-2},{0,0}},{2,{-2,2},{0,0}},{4,{-2,0,4,-2},{0,0,-1,1}},{4,{-4,2,-2,4},{0,0,-1,1}},{4,{-2,2,0,0},{0,0,0,0}},};voidgotoxy(
7、intx,inty)//光标移动函数{COORDpos;//COORD是WindowsAPI中定义的一种结构,表示一个字符在控制台屏幕上的坐标pos.X=x;pos.Y=y;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);//使光标到(x,y)这个位置}voidcolor(intb)//颜色函数{HANDLEhConsole=GetStdHandle((STD_OUTPUT_HANDLE));SetConsoleTextAttribute(