-
个人简介


💖💖💖💖 💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖 💖💖 💖 💖💖 💖💖 💖💖💖💖 💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖 💖💖 💖 💖💖 💖💖 💖💖💖💖 💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖💖💖 💖💖💖💖💖💖💖💖 💖💖💖💖💖💖 💖💖💖💖 💖💖 💖
跳动的❤💖 #include <stdio.h> #include <math.h> #include <windows.h> #include <tchar.h>
float f(float x, float y, float z) { float a = xx + 9.0f/4.0fyy + zz - 1; return aaa - xxzzz - 9.0f/80.0fyyzz*z; }
float h(float x, float z) { for(float y = 1.0f; y >= 0.0f; y -= 0.001f) if(f(x, y, z) <= 0.0f) return y; return 0.0f; }
int main() { HANDLE o = GetStdHandle(STD_OUTPUT_HANDLE); _TCHAR buffer[25][80] = { _T(' ') }; _TCHAR ramp[] = _T(".:-=+*#%@");
for(float t = 0.0f;; t += 0.1f) { int sy = 0; float s = sinf(t); float a = s*s*s*s*0.2f; for(float z = 1.3f; z > -1.2f; z -= 0.1f) { _TCHAR* p = &buffer[sy++][0]; float tz = z*(1.2f - a); for(float x = -1.5f; x < 1.5f; x += 0.05f) { float tx = x*(1.2f + a); float v = f(tx, 0.0f, tz); if(v <= 0.0f) { float y0 = h(tx, tz); float ny = 0.01f; float nx = h(tx + ny, tz) - y0; float nz = h(tx, tz + ny) - y0; float nd = 1.0f/sqrtf(nx*nx + ny*ny + nz*nz); float d = (nx + ny - nz)*nd*0.5f + 0.5f; *p++ = ramp[(int)(d*5.0f)]; } else *p++ = ' '; } } for(int y = 0; y < 25; y++) { COORD coord = {0, y}; SetConsoleCursorPosition(o, coord); WriteConsole(o, buffer[y], 80, NULL, NULL); } Sleep(30); }}
AC: Answer Correct 正确的答案 CE:Compile Easily 轻松地通过编译 PC: Pass Compile 通过编译 WA:Wonerful Answer 极好的答案 RE:Right Enough 过于正确 TLE: Time Limit Enough 时间充裕 MLE: Memory Limit Enough 内存充裕 OLE: Output Limit Enough 输出充裕 UKE: Unknown Exactness 不明情况的正确
.======. | INRI | | | | |.' '. | _ xxxx _ | | /_;-.__ / \ .-;\ | |
-._'_/'.-' | '.\ /' | | / | |/-.( | |_.\ | | \ `;| | > |/| | / // | | |// | | (\ | | `` | | | | | | | | | ——————胜利不会向山坡上的蒲公英一样脱手可得,但总有一些美好值得我们全力以赴! 死亡不是终点,遗忘才是! 大鹏一日同风起,扶摇直上九万里。
数学是火,点亮物理的灯;物理是灯,照亮化学的路;化学是路,通向生物的坑;生物是坑,埋葬学理的人。 文言是火,点亮历史宫灯;历史是灯,照亮社会之路;社会是路,通向哲学大坑;哲学是坑,埋葬文科生。
诈骗 https://xwjedu.cn/prep/assets/xiaotian.png
#include <bits/stdc++.h> #include <windows.h> #include <stdio.h> #include <conio.h> #include <time.h> using namespace std; const double pi = 3.1415926536; int toint (float a) { return ((int) (a * 10 + 5)) / 10; } void Color (int a) { if (a == 0 || a == 14 || a == 20) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); else if (a == 1 || a == 12) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE); else if (a == 2) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN); else if (a == 3) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE); else if (a == 4 || a == 11) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED); else if (a == 5 || a == 13) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); else if (a == 6) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_BLUE); else if (a == 7) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_BLUE); else if (a == 8) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); else if (a == 9) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN); else if (a == 15) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY); else if (a == 16) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN); else if (a == 17) SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED); } void SetPos (float x, float y) { int xx = toint (x), yy = toint (y); COORD pos; pos.X = yy * 2; pos.Y = xx; SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), pos); } struct node { int W, W2, S, mS; float X, Y; float vx, vy; float ax, ay; bool go, boom; } blt[100001], pig[100001], boo[100001]; int T, yX, yY, Xy, put, K, K2, Sle, What,Bot, Pit, Blt, Pig, Sco, pigk, scok,m[41][41]; void Cout (int a, int x, int y) { if (a == 1) { SetPos (x, y); Color (5); cout << put << ' '; } if (y == 202) { SetPos (pig[a].X, pig[a].Y); cout << " "; if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) { SetPos (pig[a].X - 2, pig[a].Y); cout << " "; SetPos (pig[a].X - 1, pig[a].Y); cout << " "; } else if (pig[a].W == 4) { SetPos (pig[a].X, pig[a].Y - 1); cout << " "; } else if (pig[a].W == 5) { SetPos (pig[a].X - 1, pig[a].Y); cout << " "; SetPos (pig[a].X - 1, pig[a].Y - 1); cout << " "; } } if (a == 2) { for (int i = 0; i <= 40; i++) { for (int j = 0; j <= 40; j++) { if (i <= 18 && m[i][j] == 1) { SetPos (i, j); Color (7); cout << "■"; } if (m[i][j] >= 2 && m[i][j] <= 19) { SetPos (i, j); Color (5); cout << "█"; m[i][j]++; } if (m[i][j] > 19 && m[i][j] <= 29) { SetPos (i, j); Color (0); cout << "█"; m[i][j]++; if (m[i][j] == 30) { SetPos (i, j); Color (0); cout << " "; m[i][j] = 0; } if (m[i][j] >= 31 && m[i][j] <= 49) { SetPos (i, j); Color (0); cout << "■"; m[i][j]++; } if (m[i][j] == 50) { SetPos (i, j); Color (7); cout << "■"; m[i][j] = 1; } } } } } if (y == 666) { SetPos (blt[a].X, blt[a].Y); Color (10 + blt[a].W); cout << "●"; } Color (0); } void Go (int a) { SetPos (blt[a].X, blt[a].Y); cout << " "; blt[a].X += blt[a].vx / 2; blt[a].Y += blt[a].vy / 2; blt[a].vx += blt[a].ax / 2; blt[a].vy += blt[a].ay / 2; if (blt[a].X >= 20) blt[a].X = 19; if (blt[a].X > 20 || blt[a].Y > 38 || blt[a].X < 0 || blt[a].Y <= 0) blt[a].go = 1; if (blt[a].W2 == 1 && blt[a].Y >= Xy) { blt[a].go = 1; Sle = 0; } if (blt[a].W2 == 0) { for (int i = 0; i <= blt[a].vx / 2 + 1; i++) { if (blt[a].vx > 0 && m[toint (blt[a].X) + i][toint (blt[a].Y)] == 1) { if (blt[a].W != 5) blt[a].boom = 1; blt[a].X = toint (blt[a].X) + i - 1; blt[a].Y += blt[a].vy / 2; blt[a].vx = -blt[a].vx * 0.4; blt[a].vy = blt[a].vy * 0.8; if (blt[a].W == 3) blt[a].ax = 0.5; if (blt[a].W == 7) blt[a].vx *= 2; if (blt[a].W == 10) { blt[a].go = 1; Bot++; boo[Bot].X = blt[a].X; boo[Bot].Y = blt[a].Y; boo[Bot].S = 1; boo[Bot].mS = 4; } } if (blt[a].vx < 0 && m[toint (blt[a].X) - i][toint(blt[a].Y)] == 1) { if (blt[a].W != 5) blt[a].boom = 1; blt[a].X = toint (blt[a].X) + i + 1; blt[a].Y += blt[a].vy / 2; blt[a].vx = -blt[a].vx; blt[a].vy = blt[a].vy * 0.8; if (blt[a].W == 3) blt[a].ax = 0.5; if (blt[a].W == 7) blt[a].vx *= 2; if (blt[a].W == 10) { blt[a].go = 1; Bot++; boo[Bot].X = blt[a].X; boo[Bot].Y = blt[a].Y; boo[Bot].S = 1; boo[Bot].mS = 4; } } } if (abs (blt[a].vx) <= 0.1 && abs (blt[a].vy) <= 0.1 && abs (blt[a].ay) <= 0.1) { blt[a].go = 1; if (blt[a].W == 5) { Bot++; boo[Bot].X = blt[a].X; boo[Bot].Y = blt[a].Y; boo[Bot].S = 1; boo[Bot].mS = 4; blt[a].go = 1; } } } if (blt[a].go == 0) Cout (a, 0, 666); } void Kill (int a) { if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) { Cout (a, 202, 202); pig[a].Y = 16; } if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) pig[a].W = 1; int R = rand () % 50; Cout (a, 202, 202); pig[a].X += pig[a].vx / 2; pig[a].Y += pig[a].vy / 2; pig[a].vx += pig[a].ax / 2; pig[a].vy += pig[a].ay / 2; for (int i = -2; i <= pig[a].vx / 2 + 1; i++) if (m[toint (pig[a].X) + i][toint (pig[a].Y)] == 1) { pig[a].X = toint (pig[a].X) + i - 1; pig[a].Y += pig[a].vy / 2; pig[a].vx = -pig[a].vx * 0.5; pig[a].vy = pig[a].vy * 0.8; } for (int i = Blt - 10; i <= Blt; i++) { if (pig[a].W == 5 && blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1&& abs (pig[a].Y - blt[i].Y) <= 1) { m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2; pig[a].W2++; Sco += 2; break; } if (pig[a].W == 5 && m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 &&m[toint (pig[a].X)][toint (pig[a].Y)] < 30) { m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2; pig[a].W2++; Sco += 2; break; } if (blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) { if (pig[a].W == 6) { Bot++; boo[Bot].X = pig[a].X; boo[Bot].Y = pig[a].Y; boo[Bot].S = 1; boo[Bot].mS = 4; blt[i].go = 1; } m[toint (pig[a].X)][toint (pig[a].Y)] = 2; pig[a].go = 1; Pig--; Sco += 10; break; } if (m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 && m[toint (pig[a].X)][toint (pig[a].Y)] < 30) { if (pig[a].W == 6) { Bot++; boo[Bot].X = pig[a].X; boo[Bot].Y = pig[a].Y; boo[Bot].S = 1; boo[Bot].mS = 4; } pig[a].go = 1; Pig--; Sco += 10; break; } if ((pig[a].W == 2 || pig[a].W == 3) && blt[i].go == 0 &&abs (pig[a].X - 2 - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) { m[toint (pig[a].X)][toint (pig[a].Y)] = 2; pig[a].go = 1; Pig--; Sco += 10; break; } if ((pig[a].W == 2 || pig[a].W == 3) &&m[toint (pig[a].X - 2)][toint (pig[a].Y)] >= 2&& m[toint (pig[a].X - 2)][toint (pig[a].Y)] < 30) { pig[a].go = 1; Pig--; Sco += 10; break; } } if (pig[a].go == 0) { if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) { Cout (a, 202, 202); pig[a].Y = 16; } if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) pig[a].W = 1; int Xx = toint (pig[a].X), Xy = toint (pig[a].Y); if (pig[a].W == 6) { SetPos (pig[a].X, pig[a].Y); Color (9); cout << "TN"; Color (0); } else { SetPos (pig[a].X, pig[a].Y); Color (2); cout << "●"; if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) { SetPos (pig[a].X - 2, pig[a].Y); Color (0); cout << "○"; SetPos (pig[a].X - 1, pig[a].Y); cout << "|"; } else if (pig[a].W == 4) { SetPos (pig[a].X, pig[a].Y - 1); Color (2); cout << "﹃"; } else if (pig[a].W == 5) { SetPos (pig[a].X - 1, pig[a].Y); Color (8); SetPos (pig[a].X - 1, pig[a].Y - 1); cout << "▁"; if (pig[a].W2 == 0) cout << "▅"; else if (pig[a].W2 == 1) cout << "▃"; else if (pig[a].W2 == 2) cout << "▂"; else if (pig[a].W2 == 3) { pig[a].W = 1; pig[a].W2 = 0; SetPos (pig[a].X - 1, pig[a].Y - 1); cout << " "; } } } if (pig[a].W == 2 && pig[a].X > pig[a].S) { pig[a].W = 3; pig[a].ax = -0.4; pig[a].vx = 1.5; } else if (pig[a].W == 3 && pig[a].X <= pig[a].S) { pig[a].W = 2; pig[a].ax = 0.4; pig[a].vx = -1.5; } if ((pig[a].W == 2 || pig[a].W == 3) && (pig[a].Y <= 10 || pig[a].Y >= 38)) pig[a].vy *= -1; if (pig[a].W == 4 && R == 0 && pig[a].X == 20) pig[a].vx = -((rand () % 40) / 10); if (pig[a].W == 4) { int r = rand () % 20; for (int i = Blt - 10; i <= Blt; i++) if (r <= 5 && blt[i].go == 0 && pig[a].Y - blt[i].Y <= 5 &&abs (blt[i].X - pig[a].X) <= 1.5 && r < 5) { r = 0; break; } if (r == 0) { m[toint (pig[a].X)][toint (pig[a].Y) - 2] = 10; m[toint (pig[a].X)][toint (pig[a].Y) - 3] = 2; for (int j = toint (pig[a].Y) - 1; j >= toint (pig[a].Y) - 5; j--) { for (int i = Blt - 10; i <= Blt; i++) if (blt[i].go == 0 && !(blt[i].W == 3 && blt[i].boom == 1)&& blt[i].W2 == 0 && toint (blt[i].Y) == j&& abs (blt[i].X - pig[a].X) <= 2) blt[i].vy = -2; for (int i = Pit - 50; i <= Pit; i++) if (pig[i].go == 0 && toint (pig[i].Y) == j && abs (pig[i].X - pig[a].X) <= 2) pig[i].vy = -1; } } } if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) { Cout (a, 202, 202); pig[a].Y = 16; } if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) pig[a].W = 1; if (pig[a].X > 20 || pig[a].Y > 38 || pig[a].X < 0 || pig[a].Y <= 0) { pig[a].go = 1; Pig--; Cout (a, 202, 202); } } } void Creat (int a, int p) { if (a == -1 && p == -1) { Blt++; blt[Blt].W = What; blt[Blt].W2 = 1; blt[Blt].vy = 1; blt[Blt].X = 19; blt[Blt].Y = 0; blt[Blt].boom = 1; } else if (a == 0 && p == -1) { int u = rand () % 7 + 1, U = rand() % 30; if (u >= 5) { Pit++; pig[Pit].Y = rand () % 15 + 20; pig[Pit].X = 2; pig[Pit].ax = 0.5; pig[Pit].W = 1; } else if (u == 1) { Pit++; pig[Pit].Y = rand () % 15 + 20; pig[Pit].X = 2; pig[Pit].vy = 0.5; pig[Pit].ax = 0.5; pig[Pit].S = rand () % 5 + 7; pig[Pit].W = 2; } else if (u == 2) { Pit++; pig[Pit].Y = rand () % 15 + 20; pig[Pit].X = 2; pig[Pit].ax = 0.5; pig[Pit].W = 4; } else if (u == 3) { Pit++; pig[Pit].Y = rand () % 15 + 20; pig[Pit].X = 2; pig[Pit].ax = 0.5; pig[Pit].W = 5; } else if (u == 4) { Pit++; pig[Pit].Y = rand () % 15 + 20; pig[Pit].X = 2; pig[Pit].ax = 0.5; pig[Pit].W = 6; } if (U == 1) { Bot++; boo[Bot].Y = rand () % 13 + 15; boo[Bot].X = (rand () % 4) * 3 + 8; boo[Bot].S = 0; boo[Bot].mS = rand () % 2 + 2; boo[Bot].W2 = 1; } } else { Blt++; blt[Blt].W = What; if (a == 1) { blt[Blt].X = yX; blt[Blt].Y = yY; blt[Blt].ax = 0.5; } blt[Blt].vx = -3.5 * sin (p * pi / 180); blt[Blt].vy = 3 * cos (p * pi / 180); if (p <= 45) blt[Blt].vy *= 1 + (0.33 - 0.01 * (45 - p)); if (p >= 45) blt[Blt].vy *= 1 + (0.33 - 0.01 * (p - 45)); if (blt[Blt].W == 6) { blt[Blt].vy *= 1.2; blt[Blt].ax = 0.4; } } } void Boom (int a) { if (boo[a].W2 == 0) { int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y; if (s == ms) return ; for (int i = x - s; i <= x + s; i++) for (int j = y - s; j <= y + s; j++) { float k = (i - x) * (i - x) + (j - y) * (j - y) - s * s; if (k <= s && k >= -s && i <= 20 && j <= 38 && i >= 0 && j > 0 && m[i][j] != 1) m[i][j] = 2; } boo[a].S++; } if (boo[a].W2 == 1) { int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y; if (s == ms) return ; if (y - s > 10) m[x][y - s] = 31 - 31 * (boo[a].W2 - 1); if (y + s < 40) m[x][y + s] = 31 - 31 * (boo[a].W2 - 1); boo[a].S++; } } void Move (int a) { Color (5); if (a == -2) { SetPos (17, Xy); cout << " "; SetPos (18, Xy); cout << " "; SetPos (19, Xy); cout << " "; SetPos (20, Xy); cout << " "; } if (a == -1) { SetPos (17, Xy); cout << " "; SetPos (18, Xy); cout << " ┃ ┃"; SetPos (19, Xy); cout << " ╰┳╯"; SetPos (20, Xy); cout << " ▏"; } if (a == 0) { SetPos (18, Xy); cout << " ┃"; Color (What + 10); cout << "●"; Color (5); cout << "┃"; SetPos (19, Xy); cout << " ╰┳╯"; SetPos (20, Xy); cout << " ▏"; } if (a == 1) { SetPos (18, Xy); cout << " "; Color (What + 10); cout << "●"; Color (5); cout << " ┃"; SetPos (19, Xy); cout << " ╰┳╯"; SetPos (20, Xy); cout << " ▏"; } if (a == 2) { SetPos (18, Xy); Color (What + 10); cout << "●"; Color (5); cout << "┃ ┃"; SetPos (19, Xy); cout << " ╰┳╯"; SetPos (20, Xy); cout << " ▏"; } if (a == 3) { SetPos (18, Xy); cout << " ┃ ┃"; SetPos (19, Xy); Color (What + 10); cout << "●"; Color (5); cout << "╰┳╯"; SetPos (20, Xy); cout << " ▏"; } if (a == 4) { SetPos (18, Xy); cout << " ┃ ┃"; SetPos (19, Xy); cout << " ╰┳╯"; SetPos (20, Xy); Color (What + 10); cout << "●"; Color (5); cout << " ▏"; } if (a == 5) { SetPos (18, Xy); cout << " ┃ ┃"; SetPos (19, Xy); cout << " ╰┳╯"; SetPos (20, Xy); cout << " "; Color (What + 10); cout << "●"; Color (5); cout << " ▏"; } if (a == 6) { SetPos (18, Xy); cout << " ┃ ┃"; SetPos (19, Xy); cout << " ╰┳╯"; SetPos (20, Xy); cout << " "; Color (What + 10); cout << "●"; Color (5); cout << " "; } Color (0); } void Start () { char g; Color (5); system ("cls"); SetPos (1, 1); cout << "------- 愤 怒 的 小 鸟 -------"; Color (0); SetPos (3, 1); cout << "空格瞄准,按X触发小鸟技能,←→移动弹弓"; SetPos (5, 1); cout << "猪猪技能自动触发,空中会有墙出现。"; SetPos (7, 1); cout << "危险值由命中率,猪的存活时间计算!"; SetPos (9, 1); cout << "危险值点满后失败!1500分通关!"; SetPos (1, 20); cout << "-------- 小 鸟 技 能 --------"; SetPos (3, 20); Color (11); cout << "●"; Color (0); cout << ":无技能"; SetPos (5, 20); Color (12); cout << "●"; Color (0); cout << ":分身!不同分身初速度大小相同,"; SetPos(6, 20); cout << " 方向不同。"; SetPos (7, 20); Color (13); cout << "●"; Color (0); cout << ":加速!以当前速度做匀速直线运动,"; SetPos (8, 20); cout << " 且免疫狙击猪的冲击。"; SetPos (9, 20); Color (14); cout << "●"; Color (0); cout << ":投蛋!并获得向上速度做匀速直线"; SetPos (10, 20); cout << " 运动,快达可以穿墙。"; SetPos (11, 20); Color (15); cout << "●"; Color (0); cout << ":爆炸!"; SetPos (13, 20); Color (16); cout << "●"; Color (0); cout << ":回旋!开始做向左加速运动!发射"; SetPos (14, 20); cout << " 时获得双倍水平速度。"; SetPos (15, 20); Color (17); cout << "●"; Color (0); cout << ":[被动] 弹跳力为普通鸟三倍。发射"; SetPos (16, 20); cout << " 时获得1.5倍水平、竖直速度。"; SetPos (11, 1); cout << "-------- 猪 猪 技 能 --------"; SetPos (13, 2); Color (2); cout << "●"; Color (0); cout << ":无技能"; SetPos (14, 1); Color (8); cout << "▁▅"; SetPos (15, 2); Color (2); cout << "●"; Color (0); cout << ":防御力为普通猪三倍"; SetPos (16, 2); cout << "○"; SetPos (17, 2); cout << "│:做空中简谐运动,受死范围"; SetPos (18, 2); Color (2); cout << "●"; Color (0); cout << " 为普通猪两倍。"; SetPos (19, 2); cout << " 有几率跳起或发射冲击波,冲"; SetPos (20, 1); Color (2); cout << "﹃●"; Color (0); cout << ":开小鸟与同类,可以引爆TNT!"; SetPos (18, 20); Color (5); cout << "按 y 开始游戏!"; A: if (kbhit ()) g = _getch (); if (g != 'y') goto A; } int main () { system ("mode con cols=79 lines=22"); CONSOLE_CURSOR_INFO cursor_info = {1, 0}; SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cursor_info); srand ((unsigned)time(NULL)); St: Start (); system ("cls"); memset (blt, 0, sizeof (blt)); memset (pig, 0, sizeof (pig)); memset (boo, 0, sizeof (boo)); memset (m, 0, sizeof (m)); T = put = K = K2 = Sle = What = Pig = Sco = 0; pigk = scok = -1; Xy = 4; yX = 18; yY = 6; Blt = 20; Bot = 20; Pit = 60; Color (7); SetPos (19, 14); cout << "■"; SetPos (20, 13); cout << " █▍"; m[19][14] = m[20][13] = m[20][14] = 1; SetPos (21, 0); for (int i = 0; i < 39; i++) { cout << "■"; m[21][i] = 1; } Color (0); What = rand () % 5 + 1; while (1) { if (Sco >= 1500) break; T++; K = 0; Color (0); if (Sco != scok) { SetPos (1, 1); cout << "分数:" << Sco << ' '; } if (Pig != pigk) { SetPos (3, 1); cout << "危险值:"; int aa = min (Sco / 100, 10); Pig += aa; SetPos (3, 5); if (Pig <= 2) Color (2); else if (Pig <= 4) Color (16); else if (Pig <= 6) Color (7); else if (Pig <= 9) Color (6); else if (Pig <= 12) Color (3); else if (Pig <= 15) Color (17); else Color (11); for (int i = 1; i <= Pig; i++) cout << "■"; Color (0); cout << ' ' << Pig; for (int i = 1; i <= 5; i++) cout << " "; if (Pig > 18) break; Pig -= aa; } scok = Sco; pigk = Pig; if (GetAsyncKeyState (VK_LEFT) & 0x8000 && Xy > 0) { Move (-2); Xy--; K = 1; } if (GetAsyncKeyState (VK_RIGHT) & 0x8000 && Xy < 10) { Move (-2); Xy++; K = 1; } if (K == 1) if (put == 0 && Sle == 0) Move (0); else Move (-1); if (kbhit ()) { char g = _getch (); if (g == 'x' || g == 'X') { for (int i = Blt - 10; i <= Blt; i++) { if (blt[i].go == 0 && blt[i].boom == 0 && blt[i].W != 1 && blt[i].W != 7) { blt[i].boom = 1; if (blt[i].W == 2) { Blt++; blt[Blt].W = 2; blt[Blt].vy = blt[i].vy * 1.2; blt[Blt].vx = blt[i].vx + 1; blt[Blt].ax = blt[i].ax; blt[Blt].X = blt[i].X; blt[Blt].Y = blt[i].Y; blt[Blt].boom = 1; Blt++; blt[Blt].W = 2; blt[Blt].vy = blt[i].vy * 0.7; blt[Blt].vx = blt[i].vx - 1; blt[Blt].ax = blt[i].ax; blt[Blt].X = blt[i].X; blt[Blt].Y = blt[i].Y; blt[Blt].boom = 1; } if (blt[i].W == 3) { blt[i].vy = fmax (blt[i].vy * 1.5, 2.5); blt[Blt].vx++; blt[i].ax = 0; } if (blt[i].W == 4) { blt[i].vx = -3; blt[i].ax = 0.1; Blt++; blt[Blt].boom = 1; blt[Blt].W = 10; blt[Blt].X = blt[i].X; blt[Blt].Y = blt[i].Y; blt[Blt].ax = blt[i].ax; blt[Blt].vx = 1; } if (blt[i].W == 5) { Bot++; boo[Bot].X = blt[i].X; boo[Bot].Y = blt[i].Y; boo[Bot].S = 1; boo[Bot].mS = 5; blt[i].go = 1; } if (blt[i].W == 6) { blt[i].ay = -1; blt[i].ax = 0.3; blt[i].vx = min (blt[i].vx / 2, (float)0); } break; } } } } if (GetAsyncKeyState (' ') & 0x8000 && K == 0 && Sle == 0) { if (put <= 5) { Move (1); yX = 18; yY = Xy + 1; } else if (put <= 20) { Move (2); yX = 18; yY = Xy; } else if (put <= 40) { Move (3); yX = 19; yY = Xy; } else if (put <= 60) { Move (4); yX = 20; yY = Xy; } else if (put <= 80) { Move (5); yX = 20; yY = Xy + 1; } else { Move (6); yX = 20; yY = Xy + 2; } if (put == 0) K2 = 1; if (put == 90) K2 = -1; if (K2 == 1) put += min (rand () % 7 + 1, 90 - put); if (K2 == -1) put -= min(rand() % 7 + 1, put); Cout (1, 17, Xy + 2); } if ((!(GetAsyncKeyState (' ') & 0x8000) && (put != 0)) || (put != 0 && K == 1)) { Move (-1); Creat (1, put); put = 0; yX = 18; yY = 5; Sle = 1; What = rand () % 7 + 1; Creat (-1, -1); Sco = max (Sco - 5, 0); } for (int i = Blt - 10; i <= Blt; i++) if (blt[i].go == 0) Go (i); for (int i = Bot - 10; i <= Bot; i++) if (boo[i].go == 0) { Boom (i); Cout (2, 0, 0); } for (int i = Pit - 50; i <= Pit; i++) if (pig[i].go == 0) Kill (i); if (Sle != 0) Move (-1); else if (put == 0) Move (0); if (T % 300 == 0) { system ("cls"); pigk = scok = -1; } if (T % 100 == 0) { Color (7); for (int i = 0; i <= 18; i++) for (int j = 0; j <= 40; j++) if (m[i][j] == 1 && T % 100 == 0) { SetPos (i, j); cout << "■"; } SetPos (19, 14); cout << "■"; SetPos (20, 13); cout << " █▍"; SetPos (21, 0); for (int i = 0; i < 39; i++) { cout << "■"; Color (0); } } if (T % min (50, (2000 - Sco) / 30) == 0) { Pig++; Creat (0, -1); } Sleep (30); } if (Sco < 100) if (MessageBox (NULL, "很遗憾,您输了,您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) goto St; else return 0; else if (MessageBox (NULL, "恭喜您赢了!您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) goto St; else return 0; return 0; }
https://q1.qlogo.cn/g?b=qq&nk=3509337335&s=160
炒鸡诈骗https://xwjedu.cn/file/5722/.avatar.jpg
好玩的 安慕西同款 https://www.bilibili.com/toy/MeetVerity/index.html?spm_id_from=333.788.specialRecommendByOp.0
狼人杀代码 耗时3月 纯手搓 #include #include #include #include #include #include #include #include #include #include
#ifndef _WIN32 #include <unistd.h> #endif
using namespace std;
enum Role { WEREWOLF, VILLAGER, SEER, WITCH, HUNTER };
struct Player { int id; Role role; bool alive; bool isDeadAtNight; bool savedByWitch; bool poisonedByWitch; bool witchUsedSave; bool witchUsedPoison; bool hunterCanShoot;
Player(int _id = 0) : id(_id), role(VILLAGER), alive(true), isDeadAtNight(false), savedByWitch(false), poisonedByWitch(false), witchUsedSave(false), witchUsedPoison(false), hunterCanShoot(true) {}};
class Game { private: vector players; int playerCount; int dayCount; int aliveWolf; int aliveGod; int aliveVillager;
void initRoles(); void clearScreen(); void waitForPlayer(int playerId); string getRoleName(Role r); string getRoleDesc(Role r); void printDivider(); void werewolfAction(); void seerAction(); void witchAction(); int vote(); bool checkWin(); void printGameResult();public: Game(int n); void start(); };
Game::Game(int n) : playerCount(n), dayCount(0) { for (int i = 1; i <= n; i++) { players.push_back(Player(i)); } initRoles(); aliveWolf = 0; aliveGod = 0; aliveVillager = 0; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; if (p.role == WEREWOLF) aliveWolf++; else if (p.role == VILLAGER) aliveVillager++; else aliveGod++; } }
void Game::initRoles() { vector roles; if (playerCount == 9) { for (int i = 0; i < 3; i++) roles.push_back(WEREWOLF); for (int i = 0; i < 3; i++) roles.push_back(VILLAGER); roles.push_back(SEER); roles.push_back(WITCH); roles.push_back(HUNTER); } else { int wolfCount = playerCount / 3; if (wolfCount < 1) wolfCount = 1; for (int i = 0; i < wolfCount; i++) roles.push_back(WEREWOLF); roles.push_back(SEER); roles.push_back(WITCH); roles.push_back(HUNTER); while ((int)roles.size() < playerCount) roles.push_back(VILLAGER); } srand((unsigned)time(NULL)); random_shuffle(roles.begin(), roles.end()); for (int i = 0; i < playerCount; i++) { players[i].role = roles[i]; } }
void Game::clearScreen() { #ifdef _WIN32 system("cls"); #else printf("\033c"); fflush(stdout); #endif }
void Game::waitForPlayer(int playerId) { cout << "\n>>> 请【" << playerId << "号玩家】准备操作,其他人请回避屏幕。<<<" << endl; cout << "请按回车键开始..."; cin.ignore((numeric_limits::max)(), '\n'); clearScreen(); }
string Game::getRoleName(Role r) { switch (r) { case WEREWOLF: return "狼人"; case VILLAGER: return "平民"; case SEER: return "预言家"; case WITCH: return "女巫"; case HUNTER: return "猎人"; default: return "未知"; } }
string Game::getRoleDesc(Role r) { switch (r) { case WEREWOLF: return "夜晚与狼队友睁眼,共同选择击杀一名玩家。"; case VILLAGER: return "无特殊技能,依靠推理与投票找出狼人。"; case SEER: return "每晚可查验一名玩家是好人还是狼人。"; case WITCH: return "拥有一瓶解药和一瓶毒药,每瓶限用一次,一晚最多使用一瓶。"; case HUNTER: return "死亡时可开枪带走一名玩家(被女巫毒死时无法开枪)。"; default: return ""; } }
void Game::printDivider() { cout << "\n========================================" << endl; }
void Game::werewolfAction() { printDivider(); cout << "【天黑请闭眼,狼人请睁眼】" << endl << endl; cout << "存活的狼人玩家编号:"; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; if (p.alive && p.role == WEREWOLF) cout << p.id << "号 "; } cout << endl; cout << "请狼人团队协商后选择今晚要击杀的目标(输入编号,输入0表示空刀):";
int target; while (true) { cin >> target; if (target == 0) { cout << "今晚选择空刀。" << endl; break; } if (target >= 1 && target <= playerCount && players[target-1].alive) { players[target-1].isDeadAtNight = true; cout << "今晚击杀目标为 " << target << " 号玩家。" << endl; break; } cout << "输入无效,请输入一个存活玩家的编号:"; } cout << endl << "狼人请闭眼。" << endl; cout << "按回车键继续..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); clearScreen();}
void Game::seerAction() { int seerId = -1; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; if (p.alive && p.role == SEER) { seerId = p.id; break; } } if (seerId == -1) return;
waitForPlayer(seerId); printDivider(); cout << "【预言家请睁眼】" << endl << endl; cout << seerId << "号预言家,你要查验谁的身份?(输入编号):"; int target; while (true) { cin >> target; if (target >= 1 && target <= playerCount && players[target-1].alive && target != seerId) break; cout << "输入无效,请输入一个存活且不是自己的编号:"; } Role tr = players[target-1].role; cout << endl << "查验结果:" << target << "号玩家的身份是【" << (tr == WEREWOLF ? "狼人" : "好人") << "】!" << endl; cout << endl << "预言家请闭眼。" << endl; cout << "按回车键继续..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); clearScreen();}
void Game::witchAction() { int witchId = -1; int witchIdx = -1; for (int i = 0; i < playerCount; i++) { if (players[i].alive && players[i].role == WITCH) { witchId = players[i].id; witchIdx = i; break; } } if (witchId == -1) return;
waitForPlayer(witchId); printDivider(); cout << "【女巫请睁眼】" << endl << endl; int killedId = -1; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; if (p.isDeadAtNight && !p.savedByWitch) killedId = p.id; } if (killedId != -1) { cout << "今晚 " << killedId << " 号玩家被狼人击杀了。" << endl; } else { cout << "今晚是平安夜(狼人空刀)。" << endl; } if (!players[witchIdx].witchUsedSave && killedId != -1) { cout << endl << "你是否要使用解药救 " << killedId << " 号玩家?(1=使用 0=不使用):"; int use; cin >> use; if (use == 1) { players[killedId-1].savedByWitch = true; players[witchIdx].witchUsedSave = true; cout << "你使用了解药," << killedId << " 号玩家今晚不会死亡。" << endl; killedId = -1; } else { cout << "你没有使用解药。" << endl; } } else if (players[witchIdx].witchUsedSave) { cout << "(你的解药已经用完)" << endl; } if (!players[witchIdx].witchUsedPoison) { cout << endl << "你是否要使用毒药毒杀一名玩家?(输入编号使用,输入0不使用):"; int target; while (true) { cin >> target; if (target == 0) { cout << "你没有使用毒药。" << endl; break; } bool ok = true; if (target < 1 || target > playerCount) ok = false; if (!players[target-1].alive) ok = false; if (ok && killedId != -1 && target == killedId) ok = false; if (ok) { players[target-1].poisonedByWitch = true; players[witchIdx].witchUsedPoison = true; cout << "你使用了毒药," << target << " 号玩家今晚会被毒杀。" << endl; break; } cout << "输入无效,请输入一个存活玩家的编号:"; } } else { cout << "(你的毒药已经用完)" << endl; } cout << endl << "女巫请闭眼。" << endl; cout << "按回车键继续..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); clearScreen();}
int Game::vote() { map<int, int> votes; set aliveSet; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; if (p.alive) aliveSet.insert(p.id); }
cout << endl << "现在进入投票环节,请所有存活玩家依次投票。" << endl; for (set<int>::iterator it = aliveSet.begin(); it != aliveSet.end(); ++it) { int voterId = *it; waitForPlayer(voterId); printDivider(); cout << voterId << " 号玩家请投票(投给你认为是狼人的玩家编号):"; int target; while (true) { cin >> target; if (aliveSet.count(target) > 0 && target != voterId) break; cout << "输入无效,请输入一个存活且不是自己的编号:"; } votes[target]++; cout << "你投给了 " << target << " 号玩家。" << endl << "按回车键继续..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); clearScreen(); } printDivider(); cout << "【第一轮投票结果】" << endl; int maxVotes = 0; vector<int> maxVoted; for (map<int,int>::iterator it = votes.begin(); it != votes.end(); ++it) { int id = it->first; int cnt = it->second; cout << id << " 号玩家获得 " << cnt << " 票" << endl; if (cnt > maxVotes) { maxVotes = cnt; maxVoted.clear(); maxVoted.push_back(id); } else if (cnt == maxVotes) { maxVoted.push_back(id); } } if (maxVoted.size() == 1) { return maxVoted[0]; } cout << endl << "出现平票!进入 PK 环节,上 PK 台的玩家为:"; for (int i = 0; i < (int)maxVoted.size(); i++) cout << maxVoted[i] << "号 "; cout << endl << endl; for (int i = 0; i < (int)maxVoted.size(); i++) { int id = maxVoted[i]; waitForPlayer(id); printDivider(); cout << id << " 号玩家请发表 PK 发言:" << endl; string s; cin.ignore(); getline(cin, s); cout << "按回车键继续..."; cin.get(); clearScreen(); } cout << "现在请除 PK 台上玩家外的存活玩家进行第二轮投票(仅可投给 PK 台上的玩家):" << endl; map<int, int> votes2; for (set<int>::iterator it = aliveSet.begin(); it != aliveSet.end(); ++it) { int voterId = *it; bool onPk = false; for (int i = 0; i < (int)maxVoted.size(); i++) { if (maxVoted[i] == voterId) { onPk = true; break; } } if (onPk) continue; waitForPlayer(voterId); printDivider(); cout << voterId << " 号玩家请投票(仅限 PK 台上玩家):"; int target; while (true) { cin >> target; bool isPk = false; for (int i = 0; i < (int)maxVoted.size(); i++) { if (maxVoted[i] == target) { isPk = true; break; } } if (isPk) break; cout << "输入无效,只能投给 PK 台上的玩家:"; } votes2[target]++; cout << "你投给了 " << target << " 号玩家。" << endl << "按回车键继续..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); clearScreen(); } cout << "【第二轮投票结果】" << endl; int max2 = 0; vector<int> maxVoted2; for (map<int,int>::iterator it = votes2.begin(); it != votes2.end(); ++it) { int id = it->first; int cnt = it->second; cout << id << " 号玩家获得 " << cnt << " 票" << endl; if (cnt > max2) { max2 = cnt; maxVoted2.clear(); maxVoted2.push_back(id); } else if (cnt == max2) { maxVoted2.push_back(id); } } if (maxVoted2.size() == 1) return maxVoted2[0]; cout << "再次平票,今日无人被放逐。" << endl; return -1;}
bool Game::checkWin() { if (aliveWolf == 0) return true; if (aliveGod == 0 || aliveVillager == 0) return true; return false; }
void Game::printGameResult() { printDivider(); cout << "【游戏结束】" << endl << endl; if (aliveWolf == 0) { cout << "?? 好人阵营获胜!所有狼人已被消灭。" << endl; } else { cout << "?? 狼人阵营获胜!屠边成功!" << endl; } cout << endl << "===== 身份公布 =====" << endl; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; cout << p.id << " 号玩家 —— 【" << getRoleName(p.role) << "】" << (p.alive ? "(存活)" : "(已死亡)") << endl; } printDivider(); }
void Game::start() { clearScreen(); printDivider(); cout << " ?? 欢迎来到狼人杀 Werewolf ??" << endl; cout << " 本局配置:" << playerCount << "人 屠边局" << endl; cout << " 角色包含:狼人、平民、预言家、女巫、猎人" << endl; cout << " 胜利条件:" << endl; cout << " · 好人方:消灭所有狼人" << endl; cout << " · 狼人方:杀光所有神民或所有平民" << endl; printDivider(); cout << endl << "游戏开始!现在依次查看身份。" << endl;
for (int i = 1; i <= playerCount; i++) { waitForPlayer(i); printDivider(); cout << i << " 号玩家,你的身份是:" << endl << endl; cout << " 【" << getRoleName(players[i-1].role) << "】" << endl << endl; cout << " " << getRoleDesc(players[i-1].role) << endl; cout << endl << "请牢记你的身份。按回车键后将清屏,交给下一位玩家。"; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); clearScreen(); } cout << "所有玩家已查看身份,按回车键进入第一个夜晚..."; cin.get(); while (true) { dayCount++; clearScreen(); printDivider(); cout << "========== 第 " << dayCount << " 天 夜晚 ==========" << endl; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; p.isDeadAtNight = false; p.savedByWitch = false; p.poisonedByWitch = false; } cout << "天黑请闭眼..." << endl; cout << "按回车键开始夜晚流程..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); werewolfAction(); seerAction(); witchAction(); vector<int> deadList; for (int i = 0; i < (int)players.size(); i++) { Player& p = players[i]; if (!p.alive) continue; bool dead = false; if (p.isDeadAtNight && !p.savedByWitch) dead = true; if (p.poisonedByWitch) dead = true; if (dead) { p.alive = false; deadList.push_back(p.id); if (p.role == WEREWOLF) aliveWolf--; else if (p.role == VILLAGER) aliveVillager--; else aliveGod--; if (p.role == HUNTER && p.poisonedByWitch) p.hunterCanShoot = false; } } clearScreen(); printDivider(); cout << "========== 第 " << dayCount << " 天 白天 ==========" << endl; cout << "天亮了,昨晚..." << endl << endl; vector<int> hunterShot; for (int i = 0; i < (int)deadList.size(); i++) { int id = deadList[i]; Player& p = players[id-1]; waitForPlayer(id); printDivider(); cout << id << " 号玩家,你昨夜倒牌了。你的身份是【" << getRoleName(p.role) << "】。" << endl; if (p.hunterCanShoot && p.role == HUNTER) { cout << "你是【猎人】,可以开枪带走一名玩家。" << endl; cout << "请选择要带走的目标编号(输入0放弃开枪):"; int target; while (true) { cin >> target; if (target == 0) { cout << "你选择放弃开枪。" << endl; break; } if (target >= 1 && target <= playerCount && players[target-1].alive) { Player& t = players[target-1]; t.alive = false; hunterShot.push_back(target); if (t.role == WEREWOLF) aliveWolf--; else if (t.role == VILLAGER) aliveVillager--; else aliveGod--; cout << "你开枪带走了 " << target << " 号玩家!" << endl; break; } cout << "输入无效,请输入一个存活玩家的编号:"; } } else if (p.role == HUNTER && !p.hunterCanShoot) { cout << "(你被女巫毒死,无法开枪)" << endl; } cout << endl << "请留一句遗言:" << endl; string yiyan; cin.ignore(); getline(cin, yiyan); cout << "按回车键继续..."; cin.get(); clearScreen(); } printDivider(); if (deadList.empty() && hunterShot.empty()) { cout << "昨晚是平安夜,无人死亡。" << endl; } else { cout << "昨晚死亡的玩家是:"; for (int i = 0; i < (int)deadList.size(); i++) cout << deadList[i] << "号 "; for (int i = 0; i < (int)hunterShot.size(); i++) cout << hunterShot[i] << "号(被猎人带走) "; cout << endl << "死者已发表遗言。" << endl; } printDivider(); if (checkWin()) { printGameResult(); return; } cout << endl << "现在进入发言环节,按玩家编号顺序依次发言。" << endl; cout << "按回车键开始发言..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); for (int i = 1; i <= playerCount; i++) { if (!players[i-1].alive) continue; waitForPlayer(i); printDivider(); cout << i << " 号玩家请发言:" << endl << endl; string speech; getline(cin, speech); cout << endl << "发言完毕。按回车键交给下一位..."; cin.get(); clearScreen(); } int votedOut = vote(); clearScreen(); printDivider(); if (votedOut == -1) { cout << "今日投票结果:无人被放逐。" << endl; } else { Player& out = players[votedOut-1]; out.alive = false; if (out.role == WEREWOLF) aliveWolf--; else if (out.role == VILLAGER) aliveVillager--; else aliveGod--; cout << "今日投票结果:" << votedOut << " 号玩家被放逐。" << endl; waitForPlayer(votedOut); printDivider(); cout << votedOut << " 号玩家,你被放逐了。你的身份是【" << getRoleName(out.role) << "】。" << endl; int shotTarget = -1; if (out.role == HUNTER && out.hunterCanShoot) { cout << "你是猎人,现在可以开枪带走一名玩家。" << endl; cout << "请选择要带走的目标编号(输入0放弃开枪):"; int target; while (true) { cin >> target; if (target == 0) { cout << "你选择放弃开枪。" << endl; break; } if (target >= 1 && target <= playerCount && players[target-1].alive) { Player& t = players[target-1]; t.alive = false; shotTarget = target; if (t.role == WEREWOLF) aliveWolf--; else if (t.role == VILLAGER) aliveVillager--; else aliveGod--; cout << "你开枪带走了 " << target << " 号玩家!" << endl; break; } cout << "输入无效,请输入一个存活玩家的编号:"; } } cout << endl << "请留一句遗言:" << endl; string yiyan; cin.ignore(); getline(cin, yiyan); cout << "按回车键继续..."; cin.get(); clearScreen(); if (shotTarget != -1) { printDivider(); cout << votedOut << " 号猎人开枪带走了 " << shotTarget << " 号玩家!" << endl; } } printDivider(); if (checkWin()) { printGameResult(); return; } cout << "白天结束,按回车键进入下一个夜晚..."; cin.ignore((numeric_limits<streamsize>::max)(), '\n'); cin.get(); }}
int main() { cout << "请输入玩家人数(推荐9人标准局,建议6~18人):"; int n; while (true) { cin >> n; if (n >= 6 && n <= 18) break; cout << "人数建议 6~18 人,请重新输入:"; } Game game(n); game.start(); return 0; }
贪吃蛇(耗时53天纯手搓) #include #include <conio.h> // 键盘输入头文件(Windows) #include <windows.h> // 控制台/Sleep头文件(Windows) #include #include using namespace std;
// 游戏配置常量 const int WIDTH = 40; // 游戏区宽度 const int HEIGHT = 20; // 游戏区高度 const int INIT_SPEED = 120; // 初始移动速度(毫秒/帧)
// 游戏状态变量 int snakeX[100], snakeY[100]; // 蛇身坐标数组(最多支持100节) int snakeLen; // 蛇当前长度 int foodX, foodY; // 食物坐标 int score; // 分数 int dir; // 移动方向: 1=上 2=下 3=左 4=右 bool gameOver; // 游戏结束标志
/**
-
@brief 游戏初始化 */ void Setup() { gameOver = false; dir = 4; // 默认向右移动 snakeLen = 3; // 初始长度3节 score = 0;
// 蛇初始位置(地图中央) int startX = WIDTH / 2; int startY = HEIGHT / 2; for (int i = 0; i < snakeLen; i++) { snakeX[i] = startX - i; snakeY[i] = startY; }
// 随机生成第一个食物 srand((unsigned)time(NULL)); foodX = rand() % WIDTH; foodY = rand() % HEIGHT; }
/**
-
@brief 绘制游戏画面 */ void Draw() { system("cls"); // 清屏
// 绘制顶部边框 for (int i = 0; i < WIDTH + 2; i++) cout << "#"; cout << endl;
// 绘制游戏区 for (int y = 0; y < HEIGHT; y++) { for (int x = 0; x < WIDTH; x++) { if (x == 0) cout << "#"; // 左边框
if (x == snakeX[0] && y == snakeY[0]) { cout << "O"; // 蛇头 } else if (x == foodX && y == foodY) { cout << "*"; // 食物 } else { bool isBody = false; for (int i = 1; i < snakeLen; i++) { if (snakeX[i] == x && snakeY[i] == y) { cout << "o"; // 蛇身 isBody = true; break; } } if (!isBody) cout << " "; // 空白区域 } if (x == WIDTH - 1) cout << "#"; // 右边框 } cout << endl;}
// 绘制底部边框 for (int i = 0; i < WIDTH + 2; i++) cout << "#"; cout << endl;
// 显示分数和操作提示 cout << "分数: " << score << endl; cout << "操作: WASD/方向键控制方向, ESC退出游戏" << endl; }
/**
- @brief 处理键盘输入 */ void Input() { if (_kbhit()) { // 检测是否有按键按下 switch (_getch()) { case 'w': case 'W': case 72: // W/上方向键 if (dir != 2) dir = 1; // 不能直接反向 break; case 's': case 'S': case 80: // S/下方向键 if (dir != 1) dir = 2; break; case 'a': case 'A': case 75: // A/左方向键 if (dir != 4) dir = 3; break; case 'd': case 'D': case 77: // D/右方向键 if (dir != 3) dir = 4; break; case 27: // ESC键退出 gameOver = true; break; } } }
/**
-
@brief 游戏逻辑更新 */ void Logic() { // 蛇身跟随前一节移动 for (int i = snakeLen; i > 0; i--) { snakeX[i] = snakeX[i-1]; snakeY[i] = snakeY[i-1]; }
// 移动蛇头 switch (dir) { case 1: snakeY[0]--; break; // 上 case 2: snakeY[0]++; break; // 下 case 3: snakeX[0]--; break; // 左 case 4: snakeX[0]++; break; // 右 }
// 撞墙检测 if (snakeX[0] < 0 || snakeX[0] >= WIDTH || snakeY[0] < 0 || snakeY[0] >= HEIGHT) { gameOver = true; }
// 撞自身检测 for (int i = 1; i < snakeLen; i++) { if (snakeX[0] == snakeX[i] && snakeY[0] == snakeY[i]) { gameOver = true; } }
// 吃食物判定 if (snakeX[0] == foodX && snakeY[0] == foodY) { score += 10; // 每次加10分 snakeLen++; // 蛇长度+1
// 重新生成食物(避免生成在蛇身上) bool onSnake; do { onSnake = false; foodX = rand() % WIDTH; foodY = rand() % HEIGHT; for (int i = 0; i < snakeLen; i++) { if (foodX == snakeX[i] && foodY == snakeY[i]) { onSnake = true; break; } } } while (onSnake);} }
int main() { Setup(); while (!gameOver) { Draw(); Input(); Logic(); // 速度随分数递增,最低不低于50毫秒/帧 int speed = max(INIT_SPEED - score / 2, 50); Sleep(speed); }
// 游戏结束画面 system("cls"); cout << "========================" << endl; cout << " 游戏结束!" << endl; cout << " 最终分数: " << score << endl; cout << "========================" << endl; cout << "按任意键退出..." << endl; _getch(); return 0;}
-
-
通过的题目
- B1001
- B1002
- B1003
- B1004
- B1005
- B1007
- B1008
- B1009
- B1011
- B1013
- B1015
- B1016
- B1019
- B1020
- B1021
- B1022
- B1023
- B1025
- B1028
- B1030
- B1031
- B1032
- B1033
- B1034
- B1035
- B1036
- B1037
- B1038
- B1039
- B1040
- B1041
- B1042
- B1043
- B1044
- B1045
- B1048
- B1049
- B1050
- B1051
- B1052
- B1053
- B1054
- B1055
- B1057
- B1059
- B1061
- B1062
- B1063
- B1064
- B1065
- B1069
- B1070
- B1071
- B1072
- B1073
- B1074
- B1076
- B1077
- B1078
- B1079
- B1080
- B1081
- B1082
- B1083
- B1085
- B1086
- B1088
- B1089
- B1091
- B1092
- B1093
- B1094
- B1095
- B1096
- B1102
- B1104
- B1105
- B1107
- B1109
- B1110
- B1111
- B1112
- B1113
- B1114
- B1115
- B1116
- B1117
- B1121
- B1124
- B1126
- B1133
- B1138
- B1147
- B1150
- B1155
- B1157
- B1164
- B1170
- B1173
- B1175
- B1176
- B1178
- B1180
- B1181
- B1183
- B1189
- B1206
- B1208
- B1235
- B1240
- B1307
- B1310
- B1408
- B1410
- B1414
- B1415
- B1416
- B1417
- CSPJ2020A
- CSPJ2020B
- CSPJ2021A
- NOIP2021A
- NOIPS2015A
- P515
- NOIPJ2016B
- NOIPJ2015A
- NOIPJ2015B
- P539
- P540
- 543
- 551
- 552
- P554
- 555
- W1040
- W1049
- W1052
- W1058
- W1041
- W1075
- hm1102
- hm1301
- hm1402
- hm1501
- hm1601
- hm1702
- hm1802
- W1069
- hm6101
- hm1901
- hm1902
- hm0201
- hm0202
- hm0301
- hm0302
- hm0401
- hm0402
- hm0501
- hm0502
- hm0601
- hm0602
- hm0702
- hm0802
- hm0901
- hm0902
- hm1001
- hm3601
- G1030
- G1038
- 753
- P229
- 781
- 795
- 797
- 798
- 801
- P1
- P103
- P147
- P174
- 921
- P204
- P206
- P218
- P220
- P247
- P263
- P267
- P273
- P348
- P394
- P409
- P414
- P435
- P437
- P456
- P66
- P71
- P92
- 1291
- 1293
- hm3310
- GESP202312C42
- 1321
- 1326
- 1332
- 1336
- 1351
- GESP202312C22
- 1353
- 1354
- 1360
- 1361
- 1380
- 1381
- 1384
- 1400
- 1402
- B253
- 1405
- hm4002
- 1441
- 1444
- 1445
- B373
- B378
- 1472
- 1473
- 1476
- 1477
- 1478
- 1487
- 1497
- 1532
- 1551
- 1554
- 1556
- GESP202412C51
- 1559
- 1561
- hm4402
- 1582
- 1596
- 1601
- 1602
- GESP202406C31
- GESP202406C32
- GESP202306C11
- GESP202303C12
- GESP202309C12
- GESP202403C12
- GESP202303C21
- GESP202309C22
- GESP202312C21
- GESP202406C22
- 1683
- 1706
- 1713
- 1722
- 1724
- 1743
- 1759
- 1760
- 1764
- 1765
- 1801
- 1804
- 1805
- B493
- 1830
- 1847
- B395
- 1875
- 1876
- 1877
- GESP202506C32
- 1880
- 1932
- B2042
- 1989
- 1992
- GESP202312C8T2
- GESP202403C1T2
- GESP202406C1T2
- GESP202403C3T2
- GESP202403C2T1
- GESP202403C2T2
- GESP202406C3T2
- GESP202406C2T1
- GESP202406C2T2
- GESP202403C5T2
- GESP202403C6T2
- GESP202409C1T2
- GESP202412C1T2
- GESP202409C3T2
- GESP202409C2T1
- GESP202409C2T2
- GESP202412C2T1
- GESP202412C2T2
- GESP202412C3T1
- GESP202412C3T2
- GESP202306C1P2
- GESP202303C1P2
- GESP202306C1T1
- GESP202306C1T2
- GESP202306C2P2
- GESP202303C2P2
- GESP202306C2T1
- GESP202306C2T2
- GESP202306C3P2
- GESP202306C3T2
- GESP202306C4P2
- GESP202306C4T2
- GESP202303C1T1
- GESP202303C1T2
- GESP202309C1T2
- GESP202303C2T1
- GESP202303C2T2
- GESP202312C6T2
- GESP202312C7T2
- GESP202312C1T2
- GESP202309C2T1
- GESP202309C2T2
- GESP202312C2T1
- GESP202312C2T2
- GESP202309C3T2
- GESP202309C4T2
- GESP202309C5T2
- GESP202309C6T2
- GESP202312C3T1
- GESP202312C3T2
- GESP202312C4T2
- GESP202312C5T2
- GESP202406C4T2
- GESP202409C4T2
- GESP202412C4T2
- GESP202403C7T2
- GESP202403C8T2
- GESP202406C5T2
- GESP202409C5T2
- GESP202412C5T2
- GESP202503C1T1
- GESP202503C2T1
- GESP202506C1T1
- GESP202506C2T1
- GESP202406C6T2
- GESP202406C7T2
- GESP202503C1T2
- GESP202409C6T2
- GESP202409C7T2
- GESP202409C8T2
- GESP202412C6T2
- GESP202412C7T2
- GESP202412C8T2
- GESP202503C2T2
- GESP202503C3T2
- GESP202506C1T2
- GESP202503C4T2
- GESP202503C5T2
- GESP202503C6T2
- GESP202503C7T2
- GESP202503C8T2
- GESP202506C2T2
- GESP202506C3T2
- GESP202506C4T2
- GESP202506C5T2
- GESP202506C6T2
- GESP202506C7T2
- GESP202506C8T2
- hm0701a
- hm3102
- 2325
- 2326
- GESP202509C21
- GESP202509C22
- 2369
- 2441
- C1001
- C1002
- C1003
- C1004
- C1005
- C1006
- C1007
- C1008
- GESP202512C11
- C1012
- GESP202512C21
- GESP202512C31
- GESP202512C32
- fx20261011
- GESP202606C2T1
- GESP202606C2T2
- GESP202603C2T1
- GESP202603C2T2
- GESP202509C5T2
-
最近活动
- 秋季周六上午C++作业 作业
- 2026秋季周六晚上班作业 作业
- 2026暑假周六晚上班作业2 作业
- 2026暑假周六晚上班作业 作业
- 6.8回文数 作业
- 5.25课后作业 作业
- 府学三年级5月编程小达人比赛 OI
- 26年春周六下午班c++作业(5.23) 作业
- 5.18课后作业 作业
- 2026春周六线上班xxm0502作业 作业
- 5.11课后作业 作业
- 和平一小 OI
- 4.20for循环 作业
- 2026.4.18 首师北 60最短路径 作业
- 55中4-17课后作业 作业
- 4.13课后作业 作业
- 3.30号课后作业 作业
- 2026.03.31 广渠门中学 二分练习 作业
- 3.23课后作业 作业
- 20260314 DC8-01 并查集 作业
- 2026.03.12 26春建华实验普及班 abc448和图的遍历 作业
- 20260309-和平里第一小学c++社团-求三个数的最小值 作业
- 3月6日周六模拟算法 作业
- 2026春季L1特训班周六晚上作业 作业
- 2026寒假C++特训班作业 作业
- 20251222-和平里第一小学C++社团-if应用 作业
- 20251215-和平里第一小学C++社团-逻辑运算符 作业
- 20251208-和平里第一小学C++社团-if语句嵌套 作业
- 和平里第一小学-打卡送书活动-第七天 OI
- 和平里第一小学-打卡送书活动-第六天 OI
- 和平里第一小学-打卡送书活动-第四天 OI
- 和平里第一小学-打卡送书活动-第三天 OI
- 和平里第一小学-打卡送书活动-第二天 OI
- 和平里第一小学-打卡送书活动-第一天 OI
- 和平里第一小学-打卡送书活动-模拟题 OI
- 20251201-和平里第一小学C++社团-if语句 作业
- 20251124-和平里第一小学C++社团-字符类型 作业
- 20251117-和平里第一小学C++社团-取余运算 作业
- 11.15 dc7-02 作业 作业
- 20251110-和平里第一小学C++社团-浮点数 作业
- 20251103-和平里第一小学C++社团-设置域宽和cin输入 作业
- 20251027-和平里第一小学C++社团-数据运算 作业
- 20251020-和平里第一小学C++社团-复合运算符 作业
- 20251013-和平里第一小学C++社团-累加器 作业
- 20250929-和平里第一小学C++社团-计数器 作业
- 20250922-和平里第一小学C++社团-程序结构和变量 作业
- 20250915-和平里第一小学C++社团-第一个程序 作业
题目标签
- 模拟
- 114
- 程序设计基础
- 75
- 循环结构
- 72
- 数学
- 64
- 分支结构
- 64
- 计算机基础
- 58
- 数组
- 50
- 数据结构
- 39
- 基础知识
- 37
- 字符串
- 30
- 程序阅读
- 30
- 顺序结构
- 26
- 排序
- 25
- GESP二级
- 24
- 算法基础
- 21
- 搜索
- 17
- 动态规划 DP
- 15
- GESP一级
- 14
- 枚举
- 13
- 图论
- 13