- 分享
c++答案
- @ 2026-5-9 16:36:17
答案看评论区
22 条评论
-
-
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 9 9 9 9 9 9 9 9 9 9 9 9999999999999 9 9 9 9 9 9 9 9 9 9 9 9
999 9 9 9 9 9 9 9 99 9
9 9 99 9 9
9 9 9 9 99 9 9 9 9 9 99 9 99 9 9 9 9 99 9 9 9 9
gay
-
#include #include <windows.h> #include #include using namespace std;
// 游戏地图大小 const int WIDTH = 10; const int HEIGHT = 15;
// 地图 bool map[HEIGHT][WIDTH];
// 方块形状(四种基础方块) int block[4][4][4] = { {{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}, // 正方形 {{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}}, // L形 {{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}}, // 反L {{1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}} // T形 };
// 当前方块信息 int nowType; int nowX, nowY;
// 隐藏光标 void HideCursor() { CONSOLE_CURSOR_INFO info; info.dwSize = 1; info.bVisible = FALSE; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); }
// 定位光标 void GoTo(int x, int y) { COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); }
// 生成新方块 void NewBlock() { nowType = rand() % 4; nowX = 3; nowY = 0; }
// 判断是否碰撞 bool Crash(int x, int y) { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int nx = x + j; int ny = y + i; if(nx < 0 || nx >= WIDTH || ny >= HEIGHT) return true; if(ny >= 0 && map[ny][nx]) return true; } } } return false; }
// 消除行 void ClearLine() { for(int i = HEIGHT - 1; i > 0; i--){ bool full = true; for(int j = 0; j < WIDTH; j++){ if(!map[i][j]) {full = false; break;} } if(full){ // 整行下落 for(int k = i; k > 0; k--){ for(int j = 0; j < WIDTH; j++){ map[k][j] = map[k-1][j]; } } i++; } } }
// 绘制游戏 void Draw() { GoTo(0,0); // 打印地图 for(int i = 0; i < HEIGHT; i++){ for(int j = 0; j < WIDTH; j++){ cout << (map[i][j] ? "■ " : "□ "); } cout << endl; } // 绘制当前方块 for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) GoTo(x*2, y); cout << "■"; } } } }
// 保存方块到地图 void SaveBlock() { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) map[y][x] = true; } } } }
int main() { HideCursor(); srand((unsigned)time(NULL)); NewBlock();
while(true){ Draw(); Sleep(300); // 自动下落 if(!Crash(nowX, nowY + 1)){ nowY++; }else{ SaveBlock(); ClearLine(); NewBlock(); // 游戏结束判断 if(Crash(nowX, nowY)) break; } // 按键控制 if(GetAsyncKeyState(VK_LEFT) & 0x8000 && !Crash(nowX - 1, nowY)) nowX--; if(GetAsyncKeyState(VK_RIGHT) & 0x8000 && !Crash(nowX + 1, nowY)) nowX++; if(GetAsyncKeyState(VK_DOWN) & 0x8000 && !Crash(nowX, nowY + 1)) nowY++; } GoTo(0, HEIGHT + 2); cout << "游戏结束!" << endl; return 0;}
-
#include #include <windows.h> #include #include using namespace std;
// 游戏地图大小 const int WIDTH = 10; const int HEIGHT = 15;
// 地图 bool map[HEIGHT][WIDTH];
// 方块形状(四种基础方块) int block[4][4][4] = { {{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}, // 正方形 {{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}}, // L形 {{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}}, // 反L {{1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}} // T形 };
// 当前方块信息 int nowType; int nowX, nowY;
// 隐藏光标 void HideCursor() { CONSOLE_CURSOR_INFO info; info.dwSize = 1; info.bVisible = FALSE; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); }
// 定位光标 void GoTo(int x, int y) { COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); }
// 生成新方块 void NewBlock() { nowType = rand() % 4; nowX = 3; nowY = 0; }
// 判断是否碰撞 bool Crash(int x, int y) { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int nx = x + j; int ny = y + i; if(nx < 0 || nx >= WIDTH || ny >= HEIGHT) return true; if(ny >= 0 && map[ny][nx]) return true; } } } return false; }
// 消除行 void ClearLine() { for(int i = HEIGHT - 1; i > 0; i--){ bool full = true; for(int j = 0; j < WIDTH; j++){ if(!map[i][j]) {full = false; break;} } if(full){ // 整行下落 for(int k = i; k > 0; k--){ for(int j = 0; j < WIDTH; j++){ map[k][j] = map[k-1][j]; } } i++; } } }
// 绘制游戏 void Draw() { GoTo(0,0); // 打印地图 for(int i = 0; i < HEIGHT; i++){ for(int j = 0; j < WIDTH; j++){ cout << (map[i][j] ? "■ " : "□ "); } cout << endl; } // 绘制当前方块 for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) GoTo(x*2, y); cout << "■"; } } } }
// 保存方块到地图 void SaveBlock() { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) map[y][x] = true; } } } }
int main() { HideCursor(); srand((unsigned)time(NULL)); NewBlock();
while(true){ Draw(); Sleep(300); // 自动下落 if(!Crash(nowX, nowY + 1)){ nowY++; }else{ SaveBlock(); ClearLine(); NewBlock(); // 游戏结束判断 if(Crash(nowX, nowY)) break; } // 按键控制 if(GetAsyncKeyState(VK_LEFT) & 0x8000 && !Crash(nowX - 1, nowY)) nowX--; if(GetAsyncKeyState(VK_RIGHT) & 0x8000 && !Crash(nowX + 1, nowY)) nowX++; if(GetAsyncKeyState(VK_DOWN) & 0x8000 && !Crash(nowX, nowY + 1)) nowY++; } GoTo(0, HEIGHT + 2); cout << "游戏结束!" << endl; return 0;}
-
#include <iostream> #include <windows.h> #include <cstdlib> #include <ctime> using namespace std; // 游戏地图大小 const int WIDTH = 10; const int HEIGHT = 15; // 地图 bool map[HEIGHT][WIDTH]; // 方块形状(四种基础方块) int block[4][4][4] = { {{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}, // 正方形 {{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}}, // L形 {{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}}, // 反L {{1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}} // T形 }; // 当前方块信息 int nowType; int nowX, nowY; // 隐藏光标 void HideCursor() { CONSOLE_CURSOR_INFO info; info.dwSize = 1; info.bVisible = FALSE; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); } // 定位光标 void GoTo(int x, int y) { COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } // 生成新方块 void NewBlock() { nowType = rand() % 4; nowX = 3; nowY = 0; } // 判断是否碰撞 bool Crash(int x, int y) { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int nx = x + j; int ny = y + i; if(nx < 0 || nx >= WIDTH || ny >= HEIGHT) return true; if(ny >= 0 && map[ny][nx]) return true; } } } return false; } // 消除行 void ClearLine() { for(int i = HEIGHT - 1; i > 0; i--){ bool full = true; for(int j = 0; j < WIDTH; j++){ if(!map[i][j]) {full = false; break;} } if(full){ // 整行下落 for(int k = i; k > 0; k--){ for(int j = 0; j < WIDTH; j++){ map[k][j] = map[k-1][j]; } } i++; } } } // 绘制游戏 void Draw() { GoTo(0,0); // 打印地图 for(int i = 0; i < HEIGHT; i++){ for(int j = 0; j < WIDTH; j++){ cout << (map[i][j] ? "■ " : "□ "); } cout << endl; } // 绘制当前方块 for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) GoTo(x*2, y); cout << "■"; } } } } // 保存方块到地图 void SaveBlock() { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) map[y][x] = true; } } } } int main() { HideCursor(); srand((unsigned)time(NULL)); NewBlock(); while(true){ Draw(); Sleep(300); // 自动下落 if(!Crash(nowX, nowY + 1)){ nowY++; }else{ SaveBlock(); ClearLine(); NewBlock(); // 游戏结束判断 if(Crash(nowX, nowY)) break; } // 按键控制 if(GetAsyncKeyState(VK_LEFT) & 0x8000 && !Crash(nowX - 1, nowY)) nowX--; if(GetAsyncKeyState(VK_RIGHT) & 0x8000 && !Crash(nowX + 1, nowY)) nowX++; if(GetAsyncKeyState(VK_DOWN) & 0x8000 && !Crash(nowX, nowY + 1)) nowY++; } GoTo(0, HEIGHT + 2); cout << "游戏结束!" << endl; return 0; } -
#include <cstring> #include <cmath> #include <windows.h> #include <conio.h> using namespace std; const int SIZE = 16; bool block[SIZE][SIZE][SIZE]; // 修复:DEV不能全局初始化浮点,全部清空 float x , y , z; float angle; void HideCursor() { CONSOLE_CURSOR_INFO c; c.bVisible = 0; c.dwSize = 1; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&c); } void GoTop() { COORD p; p.X = 0; p.Y = 0; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),p); } void InitMap() { memset(block,0,sizeof(block)); for(int i = 0; i < SIZE; i++) { for(int j = 0; j < SIZE; j++) { block[i][5][j] = true; } } block[10][4][10] = true; block[10][3][10] = true; block[10][2][10] = true; } void Draw3D() { GoTop(); char screen[40][80]; memset(screen,' ',sizeof(screen)); for(int nx = 0; nx < SIZE; nx++) { for(int ny = 0; ny < SIZE; ny++) { for(int nz = 0; nz < SIZE; nz++) { if(!block[nx][ny][nz]) continue; float dx = nx - x; float dy = ny - y; float dz = nz - z; double s = sin( (double)angle ); double c = cos( (double)angle ); float rx = (float)(dx*c - dz*s); float rz = (float)(dz*c + dx*s); if(rz < 0.5f) continue; int sx = 40 + (int)(rx*40/rz); int sy = 20 - (int)(dy*40/rz); if(sx > 0 && sx < 75 && sy > 0 && sy < 35) { screen[sy][sx] = '#'; } } } } for(int i = 0; i < 35; i++) { for(int j = 0; j < 75; j++) { cout << screen[i][j]; } cout << endl; } cout << "WASD移动 | Q/E旋转视角 | ESC退出"; } int main() { // 全部放main里面初始化(解决DEV第9行报错) x = 8.0f; y = 8.0f; z = 8.0f; angle = 0.0f; HideCursor(); InitMap(); while(1) { Draw3D(); if(_kbhit()) { char ch = _getch(); if(ch == 27) break; if(ch == 'a') x -= 0.4f; if(ch == 'd') x += 0.4f; if(ch == 'w') z -= 0.4f; if(ch == 's') z += 0.4f; if(ch == 'q') angle -= 0.15f; if(ch == 'e') angle += 0.15f; } Sleep(50); } return 0; } -
#include <iostream> #include <windows.h> #include <cstdlib> #include <ctime> using namespace std; // 游戏地图大小 const int WIDTH = 10; const int HEIGHT = 15; // 地图 bool map[HEIGHT][WIDTH]; // 方块形状(四种基础方块) int block[4][4][4] = { {{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}, // 正方形 {{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}}, // L形 {{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}}, // 反L {{1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}} // T形 }; // 当前方块信息 int nowType; int nowX, nowY; // 隐藏光标 void HideCursor() { CONSOLE_CURSOR_INFO info; info.dwSize = 1; info.bVisible = FALSE; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); } // 定位光标 void GoTo(int x, int y) { COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } // 生成新方块 void NewBlock() { nowType = rand() % 4; nowX = 3; nowY = 0; } // 判断是否碰撞 bool Crash(int x, int y) { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int nx = x + j; int ny = y + i; if(nx < 0 || nx >= WIDTH || ny >= HEIGHT) return true; if(ny >= 0 && map[ny][nx]) return true; } } } return false; } // 消除行 void ClearLine() { for(int i = HEIGHT - 1; i > 0; i--){ bool full = true; for(int j = 0; j < WIDTH; j++){ if(!map[i][j]) {full = false; break;} } if(full){ // 整行下落 for(int k = i; k > 0; k--){ for(int j = 0; j < WIDTH; j++){ map[k][j] = map[k-1][j]; } } i++; } } } // 绘制游戏 void Draw() { GoTo(0,0); // 打印地图 for(int i = 0; i < HEIGHT; i++){ for(int j = 0; j < WIDTH; j++){ cout << (map[i][j] ? "■ " : "□ "); } cout << endl; } // 绘制当前方块 for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) GoTo(x*2, y); cout << "■"; } } } } // 保存方块到地图 void SaveBlock() { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) map[y][x] = true; } } } } int main() { HideCursor(); srand((unsigned)time(NULL)); NewBlock(); while(true){ Draw(); Sleep(300); // 自动下落 if(!Crash(nowX, nowY + 1)){ nowY++; }else{ SaveBlock(); ClearLine(); NewBlock(); // 游戏结束判断 if(Crash(nowX, nowY)) break; } // 按键控制 if(GetAsyncKeyState(VK_LEFT) & 0x8000 && !Crash(nowX - 1, nowY)) nowX--; if(GetAsyncKeyState(VK_RIGHT) & 0x8000 && !Crash(nowX + 1, nowY)) nowX++; if(GetAsyncKeyState(VK_DOWN) & 0x8000 && !Crash(nowX, nowY + 1)) nowY++; } GoTo(0, HEIGHT + 2); cout << "游戏结束!" << endl; return 0; } -
#include <iostream> #include <windows.h> #include <cstdlib> #include <ctime> using namespace std; // 游戏地图大小 const int WIDTH = 10; const int HEIGHT = 15; // 地图 bool map[HEIGHT][WIDTH]; // 方块形状(四种基础方块) int block[4][4][4] = { {{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}, // 正方形 {{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}}, // L形 {{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}}, // 反L {{1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}} // T形 }; // 当前方块信息 int nowType; int nowX, nowY; // 隐藏光标 void HideCursor() { CONSOLE_CURSOR_INFO info; info.dwSize = 1; info.bVisible = FALSE; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); } // 定位光标 void GoTo(int x, int y) { COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } // 生成新方块 void NewBlock() { nowType = rand() % 4; nowX = 3; nowY = 0; } // 判断是否碰撞 bool Crash(int x, int y) { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int nx = x + j; int ny = y + i; if(nx < 0 || nx >= WIDTH || ny >= HEIGHT) return true; if(ny >= 0 && map[ny][nx]) return true; } } } return false; } // 消除行 void ClearLine() { for(int i = HEIGHT - 1; i > 0; i--){ bool full = true; for(int j = 0; j < WIDTH; j++){ if(!map[i][j]) {full = false; break;} } if(full){ // 整行下落 for(int k = i; k > 0; k--){ for(int j = 0; j < WIDTH; j++){ map[k][j] = map[k-1][j]; } } i++; } } } // 绘制游戏 void Draw() { GoTo(0,0); // 打印地图 for(int i = 0; i < HEIGHT; i++){ for(int j = 0; j < WIDTH; j++){ cout << (map[i][j] ? "■ " : "□ "); } cout << endl; } // 绘制当前方块 for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) GoTo(x*2, y); cout << "■"; } } } } // 保存方块到地图 void SaveBlock() { for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(block[nowType][i][j]){ int x = nowX + j; int y = nowY + i; if(y >= 0) map[y][x] = true; } } } } int main() { HideCursor(); srand((unsigned)time(NULL)); NewBlock(); while(true){ Draw(); Sleep(300); // 自动下落 if(!Crash(nowX, nowY + 1)){ nowY++; }else{ SaveBlock(); ClearLine(); NewBlock(); // 游戏结束判断 if(Crash(nowX, nowY)) break; } // 按键控制 if(GetAsyncKeyState(VK_LEFT) & 0x8000 && !Crash(nowX - 1, nowY)) nowX--; if(GetAsyncKeyState(VK_RIGHT) & 0x8000 && !Crash(nowX + 1, nowY)) nowX++; if(GetAsyncKeyState(VK_DOWN) & 0x8000 && !Crash(nowX, nowY + 1)) nowY++; } GoTo(0, HEIGHT + 2); cout << "游戏结束!" << endl; return 0; } 操作说明 - ← →:左右移动方块 - ↓:加速下落 - 自动下落、满行消除、游戏结束判定 适合学习的知识点 - 二维数组做地图 - Windows控制台API(光标隐藏、定位) - 按键检测、碰撞判断 - 循环、嵌套循环、布尔数组 -
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; //玩家结构体 struct Player{ int id; int role; // 0平民 1狼人 2预言家 bool alive; }; Player p[7]; //1~6号玩家 //初始化身份:2狼+1预言家+3平民 void init(){ srand((unsigned)time(NULL)); //全部默认平民、存活 for(int i = 1; i <= 6; i++){ p[i].id = i; p[i].role = 0; p[i].alive = true; } //预言家随机一名 int yu = rand() % 6 + 1; p[yu].role = 2; //两只狼人,不能重复、不能是预言家 int w1,w2; do{ w1 = rand() % 6 + 1; }while(w1 == yu); do{ w2 = rand() % 6 + 1; }while(w2 == yu || w2 == w1); p[w1].role = 1; p[w2].role = 1; } //统计存活狼人数量 int wolfNum(){ int cnt = 0; for(int i = 1; i <= 6; i++){ if(p[i].alive && p[i].role == 1) cnt++; } return cnt; } //统计存活总人数 int aliveNum(){ int cnt = 0; for(int i = 1; i <= 6; i++){ if(p[i].alive) cnt++; } return cnt; } int main(){ init(); cout << "====== 6人简易狼人杀 ======\n"; cout << "身份配置:2狼人 + 1预言家 + 3平民\n"; cout << "规则:狼人杀光好人获胜,好人投出全部狼人获胜\n\n"; while(true){ //==========天黑阶段========== cout << "-------- 天黑请闭眼 --------\n"; //1.预言家查验 for(int i = 1; i <= 6; i++){ if(p[i].alive && p[i].role == 2){ int check; cout << "[预言家]请查验一名玩家(1-6):"; cin >> check; if(p[check].role == 1){ cout << "结果:该玩家是狼人!\n\n"; }else{ cout << "结果:该玩家是好人!\n\n"; } } } //2.狼人杀人 int kill; cout << "[狼人]请选择杀害玩家:"; cin >> kill; if(p[kill].alive){ p[kill].alive = false; cout << "玩家" << kill << " 倒在了黑夜中\n\n"; }else{ cout << "此人已死亡,本轮无人死亡\n\n"; } //判断游戏结束 int wolf = wolfNum(); int all = aliveNum(); if(wolf == 0){ cout << "=== 好人胜利!狼人全部淘汰 ===\n"; break; } if(wolf >= all - wolf){ cout << "=== 狼人胜利!好人被压制 ===\n"; break; } //==========天亮投票========== cout << "-------- 天亮了 --------\n"; int vote; cout << "请投票放逐一名玩家:"; cin >> vote; if(p[vote].alive){ p[vote].alive = false; cout << "玩家" << vote << " 被大家投票出局\n\n"; }else{ cout << "此人已死亡,投票无效\n\n"; } //再次判断结束 wolf = wolfNum(); all = aliveNum(); if(wolf == 0){ cout << "=== 好人胜利!狼人全部淘汰 ===\n"; break; } if(wolf >= all - wolf){ cout << "=== 狼人胜利!好人被压制 ===\n"; break; } } //公布全部身份 cout << "\n====== 本局身份公示 ======\n"; for(int i = 1; i <= 6; i++){ cout << "玩家" << i << ":"; if(p[i].role == 0) cout << "平民"; if(p[i].role == 1) cout << "狼人"; if(p[i].role == 2) cout << "预言家"; if(!p[i].alive) cout << "(已死亡)"; cout << endl; } return 0; } -
#include <iostream> using namespace std; int main(){ int time,count,ming,liang,tian; bool flag; time=0; count=1; ming=liang=tian=0; do{ flag=0; time++; if(ming<9){ flag=1; ming++; } if(liang<=9&&time%2==0){ flag=1; liang++; }if(tian<9&&time%4==0){ flag=1; tian++; } }while(ming+liang+tian<9*3); cout<<count<<endl; return 0; }
- 1