加密代码
2025-10-09 18:51:04
发布于:浙江
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include <iostream>
using namespace std;
class Color {
private:
HANDLE hConsole;
WORD defaultColor;
public:
Color() {
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(hConsole, &info);
defaultColor = info.wAttributes;
}
void set(int color) {
SetConsoleTextAttribute(hConsole, color);
}
void reset() {
SetConsoleTextAttribute(hConsole, defaultColor);
}
// 常用颜色
void red() { set(12); }
void green() { set(10); }
void white() { set(7); }
void black() { set(0); }
void lan() { set(1); }
void lv() { set(2); }
void qianlv() { set(3); }
void hong() { set(4); }
void zi() { set(5); }
void zz() { set(8); }
void huang() { set(6); }
};
int mai0(int fvsjhdvhjsd)
{
Color color;
char l[17][17];
srand(time(0));
int ans=0;
printf(" ");
Sleep(300);
printf("猛");
Sleep(300);
printf("攻");
Sleep(300);
printf(" ");
Sleep(300);
printf("&&");
Sleep(300);
printf(" ");
Sleep(300);
printf("扫");
Sleep(300);
printf("雷");
Sleep(300);
printf("\n");
Sleep(300);
printf(" ");
Sleep(300);
printf("原");
Sleep(300);
printf("创:");
color.red(); // 设置为红色
Sleep(300);
printf("Z");
Sleep(300);
printf("C");
color.white();
Sleep(300);
printf(" ");
color.green();
Sleep(300);
printf("3");
color.lan();
Sleep(300);
printf(".");
color.zz();
Sleep(300);
printf("0");
color.qianlv();
Sleep(300);
printf("p");
color.hong();
Sleep(300);
printf("r");
color.zi();
Sleep(300);
printf("o");
color.white();
Sleep(300);
printf("\n");
Sleep(300);
printf(" ");
system("pause");
printf("\n");
for(int i=1;i<=10;i++)
{
for(int j=1;j<=10;j++)
{
l[i][j]='*';
}
}
l[rand()%10+1][rand()%10+1]='#';
l[rand()%10+1][rand()%10+1]='#';
l[rand()%10+1][rand()%10+1]='#';
int w=3,i=0;
while(1)
{
i++;
i%=2;
int x,y;
if(w==2)
{
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你扫到了一个雷了!!!!!!!!你牛逼!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
}
else if(w==1)
{
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你扫到了两个雷了!!!!!!!!!你真棒!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
}
printf(" 1 2 3 4 5 6 7 8 9 10\n");
for(int i=1;i<=10;i++)
{
if(i==10)
{
printf("%d ",i);
}
else
{
printf("%d ",i);
}
for(int j=1;j<=10;j++)
{
if(l[i][j]=='#')
{
printf("* ");
}
else
{
cout<<l[i][j]<<" ";
}
}
printf("\n");
}
cout<<"请输入你要的X坐标:";
cin>>x;
cout<<"请输入你要的Y坐标:";
cin>>y;
if(l[x][y]=='#')
{
l[x][y]='^';
w--;
cout<<'\a';
if(w==0)
{
system("cls");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!你赢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
Sleep(10000);
system("cls");
return 0;
}
}
else
{
l[x][y]='@';
}
system("cls");
}
}
int mai1(int hgd)
{
Color color;
srand(time(0));
int ans=0;
printf(" ");
Sleep(300);
printf("猛");
Sleep(300);
printf("攻");
Sleep(300);
printf(" ");
Sleep(300);
printf("&&");
Sleep(300);
printf(" ");
Sleep(300);
printf("计");
Sleep(300);
printf("时");
Sleep(300);
printf("器");
Sleep(300);
printf("\n");
Sleep(300);
printf(" ");
Sleep(300);
printf("原");
Sleep(300);
printf("创:");
color.red(); // 设置为红色
Sleep(300);
printf("Z");
Sleep(300);
printf("C");
color.white();
Sleep(300);
printf(" ");
color.green();
Sleep(300);
printf("3");
color.lan();
Sleep(300);
printf(".");
color.zz();
Sleep(300);
printf("0");
color.qianlv();
Sleep(300);
printf("p");
color.hong();
Sleep(300);
printf("r");
color.zi();
Sleep(300);
printf("o\n");
color.white();
Sleep(300);
printf(" ");
system("pause");
printf("\n");
system("cls");
printf("按a结束,");
system("pause");
system("cls");
long long q=0,w=0,e=0,ooo=0;
while(ooo==0)
{
if(_kbhit())
{
switch(_getch())
{
case'a':ooo++; break;
}
}
else
{
q+=4;
if(q==100)
{
q=0;
w++;
if(w==60)
{
e++;
}
}
system("cls");
printf("%lld:%lld:%lld",e,w,q);
}
Sleep(1);
}
system("pause");
return ooo;
}
const int WIDTH = 20;
const int HEIGHT = 15;
const int MAX_SNAKE = 100;
const int UP = 1;
const int DOWN = 2;
const int LEFT = 3;
const int RIGHT = 4;
int snakeX[MAX_SNAKE];
int snakeY[MAX_SNAKE];
int snakeLength = 3;
int direction = RIGHT;
int foodX, foodY;
int score = 0;
bool gameOver = false;
void hideCursor() {
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursorInfo;
cursorInfo.bVisible = false;
SetConsoleCursorInfo(console, &cursorInfo);
}
void initGame() {
snakeX[0] = WIDTH -19;
snakeY[0] = HEIGHT -15;
snakeX[1] = WIDTH ;
snakeY[1] = HEIGHT ;
snakeX[2] = WIDTH;
snakeY[2] = HEIGHT;
srand(time(0));
foodX = rand() % (WIDTH - 2) + 1;
foodY = rand() % (HEIGHT - 2) + 1;
}
void drawGame() {
Color color;
system("cls");
for (int i = 0; i < WIDTH; i++) {
cout << "#";
}
cout << endl;
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
if (x == 0 || x == WIDTH - 1) {
cout << "#";
}
else {
bool isSnake = false;
for (int i = 0; i < snakeLength; i++) {
if (snakeX[i] == x && snakeY[i] == y) {
cout << (i == 0 ? "●" : "○");
isSnake = true;
break;
}
}
if (!isSnake) {
if (x == foodX && y == foodY) {
color.green();
cout << "★";
color.white();
}
else {
cout << " ";
}
}
}
}
cout << endl;
}
for (int i = 0; i < WIDTH; i++) {
cout << "#";
}
cout << endl;
cout << "得分: " << score << " | 方向键控制 | 按Q退出" << endl;
}
void handleInput() {
if (_kbhit()) {
switch (_getch()) {
case 72:
if (direction != DOWN)
direction = UP;
break;
case 80:
if (direction != UP)
direction = DOWN;
break;
case 75:
if (direction != RIGHT)
direction = LEFT;
break;
case 77:
if (direction != LEFT)
direction = RIGHT;
break;
case 'q':
case 'Q':
gameOver = true;
break;
}
}
}
void moveSnake() {
for (int i = snakeLength - 1; i > 0; i--) {
snakeX[i] = snakeX[i - 1];
snakeY[i] = snakeY[i - 1];
}
if (direction == UP)
snakeY[0]--;
if (direction == DOWN)
snakeY[0];
if (direction == LEFT)
snakeX[0]--;
if (direction == RIGHT)
snakeX[0];
if (snakeX[0] <= 0 || snakeX[0] >= WIDTH - 1 ||
snakeY[0] < 0 || snakeY[0] >= HEIGHT) {
gameOver = true;
}
for (int i = 1; i < snakeLength; i++) {
if (snakeX[0] == snakeX[i] && snakeY[0] == snakeY[i]) {
gameOver = true;
}
}
if (snakeX[0] == foodX && snakeY[0] == foodY) {
score += 10;
snakeLength++;
bool foodOnSnake;
do {
foodOnSnake = false;
foodX = rand() % (WIDTH - 2) + 1;
foodY = rand() % (HEIGHT - 2) + 1;
for (int i = 0; i < snakeLength; i++) {
if (snakeX[i] == foodX && snakeY[i] == foodY) {
foodOnSnake = true;
break;
}
}
} while (foodOnSnake);
}
}
int mai2(int hdr) {
initGame();
hideCursor();
while (!gameOver) {
drawGame();
handleInput();
moveSnake();
Sleep(300);
}
system("cls");
cout << "===== 游戏结束 =" << endl;
cout << "你的得分: " << score << endl;
cout << "================" << endl;
cout << "按任意键关闭窗口" << endl;
cout << "尤其鸣谢豆包(www.doubao)" << endl;
system("pause");
return 0;
}
int main()
{
while(true)
{
int a;
system("cls");
printf("0.扫雷\n1.计时器\n2.贪吃蛇\n6.退出\n请选择:");
cin>>a;
system("cls");
if(a==0)
{
a+=mai0(0);
}
else if(a==1)
{
a+=mai1(0);
}
else if(a==2)
{
a+=mai2(0);
}
else if(a==6)
{
return 0;
}
}
}
这里空空如也
有帮助,赞一个