user-0 提问: 俄罗斯方块，想问下，红色部分为什么不成功，我利用的是坐标求解

回复:
user: user-1
content: 同为自学者，向楼主问好。 2楼网友排版的意思是这样： #include<stdio.h> #include<conio.h> #include<windows.h> #include<stdlib.h> #include<time.h> #define M 27 #define N 20 int a = 0, b = 5; int id; int score = 0, next, map[M][N] = { 0 }, gamespeed = 300; int shape[28][6] = { { 0, -1, 0, -2, 1, 0 }, { 0, 1, 1, 0, 2, 0 }, { -1, 0, 0, 1, 0, 2 }, { 0, -1, -1, 0, -2, 0 }, { 0, -1, 0, 1, -1, 0 }, { 0, 1, 1, 0, -1, 0 }, { 1, 0, 0, -1, 0, 1 }, { 1, 0, -1, 0, 0, -1 }, { -1, 1, 0, 1, 1, 0 }, { 0, -1, 1, 0, 1, 1 }, { -1, 0, 0, -1, 1, -1 }, { -1, -1, -1, 0, 0, 1 }, { -1, 0, 0, 1, 1, 1 }, { 0, 1, 1, -1, 1, 0 }, { -1, 0, 0, 1, 1, 1 }, { 0, 1, 1, -1, 1, 0 }, { -1, 0, 0, -1, 0, -2 }, { -1, 0, -2, 0, 0, 1 }, { 0, 1, 0, 2, 1, 0 }, { 0, -1, 1, 0, 2, 0 }, { 0, 1, 1, 0, 1, 1 }, { 0, -1, 1, 0, 1, -1 }, { -1, 0, 0, -1, -1, -1 }, { -1, 0, -1, 1, 0, 1 }, { 0, 1, 0, 2, 0, 3 }, { 1, 0, 2, 0, 3, 0 }, { 0, -1, 0, -2, 0, -3 }, { -1, 0, -2, 0, -3, 0 } }; void gotoxy(int x, int y) {     COORD c;     c.X = x - 1;     c.Y = y - 1;     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c); } void gameover(int h[M][N]) {     int i, j, flag = 0;     for (j = 1; j < 17; j++)     if (h[1][j] != 0)     {         flag = 0;         break;     }     if (flag == 1)     {         for (i = 1; i < 17; i++)         {             gotoxy(2, i + 1);             for (j = 1; j < 11; j++)                 printf("空心方块");             gotoxy(7, 9);             printf("game over!");             gotoxy(1, 19);             exit(0);         }     } } void block(int x, int y, int h[M][N]) {     int i;     h[x][y] = 3;     for (i = 0; i < 6; i += 2)         h[x + shape[id][i]][y + shape[id][i + 1]] = 3; } void clsc(int x, int y, int h[M][N]) {     int i;     h[x][y] = 0;     for (i = 0; i < 6; i += 2)         h[x + shape[id][i]][y + shape[id][i + 1]] = 0; } int judge(int x, int y, int h[M][N]) {     int i;     if (h[x][y] != 0)         return 0;     for (i = 0; i < 6; i += 2)     if (h[x + shape[id][i]][y + shape[id][i + 1]] != 0)         return 0;     return 1; } void print(int h[M][N]) {     int i, j;     for (i = 0; i < 19; i++)     {         for (j = 0; j < 12; j++)         {             if (i == 18) h[i][j] = 2;             if (j == 0 || j == 11)h[i][j] = 1;                   if (h[i][j] == 0)                 printf("  ");             if (h[i][j] == 1)                 printf("|");             if (h[i][j] == 2)                 printf("--");             if (h[i][j] == 3)                 printf("实心方块");             if (i == 1 && j == 11)printf("next:");             if (i == 11 && j == 11)printf("score:%d", score);             if (i == 14 && j == 11)printf("speed:%d", score / 100 + 1);         }         printf("\n");     } }   void ne(int h[M][N])        {     int i, j;     for (i = 0; i < 6; i += 2)         h[6 + shape[id][i]][16 + shape[id][i + 1]] = 0;     h[6][16] = 3;     for (j = 0; j < 6; j += 2)         h[6 + shape[next][j]][16 + shape[next][j + 1]] = 3; } void main() {     int i, j, id;     int flag = 0;     srand(time(NULL));     id = rand() % 27;     print(map);     while (1)     {         next = rand() % 27;         id = next;         ne(map);         while (!_kbhit())         {             if (judge(a + 1, b, map) == 1)             {                 clsc(a, b, map);                 block(a++, b, map);             }             else             {                 for (i = 1; i < 17; i++)                 for (j = 1; j < 11; j++)                 if (map[i][j] != 3)                 {                     flag = 1;                     break;                 }                 if (flag == 0)                     map[i][j] = map[i - 1][j];                 print(map);                 a = 0;                 b = 5;                 score += 10;                 if (score % 100 == 0) gamespeed -= 50;                 Sleep(gamespeed);             }         }         switch (_getch())         {         case'a':case'A':if (judge(a, b - 1, map) == 1)clsc(a, b, map), block(a, --b, map); break;         case'd':case'D':if (judge(a, b + 1, map) == 1)clsc(a, b, map), block(a, ++b, map); break;         case's':case'S':if (judge(a + 1, b, map) == 1)clsc(a, b, map), block(a++, b, map); break;         case'w':case'W':if (id % 4 == 0 && id != 0)id -= 4, block(a, b, map); break;         }     } }

user: user-0
content: 我是新手，我自学的，排版的问题我暂时还不知道应该怎么做，我知道你说的自己调，我是单步调试调试了几天我才问的，所以有些东西谁都知道自己会才最好，但是真的没有办法才求助的

user: user-2
content: 楼主你先排版一下吧，这么乱怎么看啊

user: user-3
content: 代码功能归根结底不是别人帮自己看或讲解或注释出来的；而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。 提醒：再牛×的老师也无法代替学生自己领悟和上厕所！ 单步调试和设断点调试（VS IDE中编译连接通过以后，按F10或F11键单步执行，按Shift+F11退出当前函数；在某行按F9设断点后按F5执行停在该断点处。）是程序员必须掌握的技能之一。