C/C++实现老鼠走迷宫
老鼠形象可以辨认,可以用上下左右操纵老鼠;正确检测结果,若老鼠在规定的时间内走到粮仓,提示成功,否则提示失败。代码分为3个文件:main.cpp、play.h、play.cpp。
main.cpp:
#include <iostream>
#include <windows.h>
#include "play.h"
#include <stdio.h>
using namespace std;
/* run this program using the console pauser or add your own _getch, system("pause") or input loop */
int main()
{
int Count = 0;
cout << "欢迎使用自制迷宫游戏,Are you ready?";
Sleep(500);
cout << ".";
Sleep(500);
cout << ".";
Sleep(500);
cout << ".";
// system("cls");
// cout<<"\t\t*************************************************"<<endl;
// cout<<"\t\t* *"<<endl;
// cout<<"\t\t* 1.开始游戏 *"<<endl;
// cout<<"\t\t* *"<<endl;
// cout<<"\t\t* 2.编辑游戏 *"<<endl;
// cout<<"\t\t* *"<<endl;
// cout<<"\t\t* 3.退出游戏 *"<<endl;
// cout<<"\t\t* *"<<endl;
// cout<<"\t\t*************************************************"<<endl;
Player play_1(11, 11);
Player play_2(13, 13);
Player play_3(15, 15);
int Menu;
while (1)
{
if (Count < 1)
{
system("cls");
cout << "\t\t*************************************************" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t* 1.开始游戏 *" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t* 2.编辑游戏 *" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t* 3.查看最短路径与所有路径 *" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t* 4.退出游戏 *" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t*************************************************" << endl;
}
else if (Count >= 1)
{
system("cls");
cout << "\t\t*************************************************" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t* 1.开始游戏 *" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t* 2.编辑游戏 *" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t* 3.退出游戏 *" << endl;
cout << "\t\t* *" << endl;
cout << "\t\t*************************************************" << endl;
}
cin >> Menu;
system("cls");
if (Menu == 1)
{
cout << "*******************************游戏说明*****************************" << endl;
cout << "请使用键盘↑↓←→移动老鼠,在规定时间内用尽量少的步骤帮老鼠找到粮仓" << endl;
system("cls");
cout << "\t\t 第一关 " << endl;
Sleep(500);
play_1.show_Map();
play_1.Move();
play_1.KeepMap();
cout << "\t\t 请进行你的选择 " << endl;
cout << "\t\t 1.继续游戏 " << endl;
cout << "\t\t 2.结束游戏 " << endl;
int choice, choice2;
cin >> choice;
if (choice == 1)
{
cout << "\t\t 第二关 " << endl;
Sleep(500);
play_2.show_Map();
play_2.Move();
play_2.KeepMap();
cout << "\t\t 请进行你的选择 " << endl;
cout << "\t\t 1.继续游戏 " << endl;
cout << "\t\t 2.结束游戏 " << endl;
cin >> choice2;
if (choice2 == 1)
{
cout << "\t\t 第三关 " << endl;
cout << "\t\t 请进行你的选择 " << endl;
cout << "\t\t 1.继续游戏 " << endl;
cout << "\t\t 2.结束游戏 " << endl;
Sleep(500);
play_3.show_Map();
play_3.Move();
play_3.KeepMap();
cout << "您已通关,感谢使用" << endl;
break;
}
else if (choice2 == 2)
{
cout << "游戏结束,感谢使用" << endl;
break;
}
}
else if (choice == 2)
{
cout << "游戏结束,感谢使用" << endl;
break;
}
}
else if (Menu == 2)
{
cout << "\t 请选择想要编辑的关卡 " << endl;
cout << "\t\t 1.第一关 " << endl;
cout << "\t\t 2.第二关 " << endl;
cout << "\t\t 3.第三关 " << endl;
int choice3;
cin >> choice3;
if (choice3 == 1)
{
play_1.EditorMap();
}
else if (choice3 == 2)
{
play_2.EditorMap();
}
else if (choice3 == 3)
{
play_3.EditorMap();
}
system("cls");
}
else if (Menu == 3)
{
cout << "亲,您只有一次查看机会哦╭●★★●╰。。。";
Sleep(2000);
if (Count < 1)
{
Count++;
cout << "\t\t 请输入想要查看的关卡 " << endl;
cout << "\t\t 1.第一关 " << endl;
cout << "\t\t 2.第二关 " << endl;
cout << "\t\t 3.第三关 " << endl;
int Choice;
cin >> Choice;
if (Choice == 1)
{
play_1.Pre_Short();
}
else if (Choice == 2)
{
play_2.Pre_Short();
}
else if (Choice == 3)
{
play_3.Pre_Short();
}
}
}
if (Count < 1)
{
if (Menu == 4)
{
cout << "感谢使用" << endl;
break;
}
}
else if (Count > 1)
{
if (Menu == 3)
{
cout << "感谢小主的使用" << endl;
break;
}
}
}
return 0;
}
play.cpp:
#include <iostream>
#include "play.h"
#include <windows.h>
#include <conio.h>
#include <time.h>
using namespace std;
void Player::Push()
{
front = rear + 1;
rear = 0;
top = -1;
top++;
Mp[top] = MpQueue[front - 1];
int direc1[4][2] = { 1,0,0,1,0,-1,-1,0 }; //定义方向
while (front != rear)
{
front--;
for (int j = 0; j < 4; j++)
{
if (Mp[top].x + direc1[j][0] == MpQueue[front - 1].x && Mp[top].y + direc1[j][1] == MpQueue[front - 1].y)
{
top++;
Mp[top] = MpQueue[front - 1];
}
}
}
}
void Player::show()
{
cout << "鼠";
for (int i = 0; i <= top; i++)
{
cout << "(" << Mp[i].x << "," << Mp[i].y << ")"
<< "->";
}
cout << "仓";
system("pause>nul");
}
void Player::Move()
{
time_t Start;
time_t Over;
int Count = 100;
char Enter;
int Time = 30;
int a, b = 0, c = Map_Length / 2, d = Map_Width / 2, i, j;
Start = time(NULL);
while (Time >= 0)
{
Over = time(NULL);
a = Over - Start;
if (_kbhit() == 0)
{
if (b != a)
{
system("cls");
for (i = 1; i <= Map_Length; i++)
{
for (j = 1; j <= Map_Length; j++)
{
if (Map[i][j].data == 1)
{
cout << "■";
}
else if (Map[i][j].data == 0)
{
cout << " ";
}
else if (Map[i][j].data == 2)
{
cout << "鼠";
}
else if (Map[i][j].data == 3)
{
cout << "仓";
}
else if (Map[i][j].data == 4)
{
cout << " ";
}
}
cout << endl;
}
cout << "剩余时间" << Time-- << "秒" << endl;
b = a;
if (Time == -1)
{
system("cls");
cout << "闯关失败" << endl;
exit(1);
break;
}
}
}
if (_kbhit() != 0)
{
Enter = _getch();
system("cls");
if (Enter == -32)
{
Enter = _getch();
if (Enter == 75)
{
if (Map[c][d - 1].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c][d - 1].data = 2;
Map[c][d].data = 4;
d = d - 1;
Count--;
}
}
else if (Enter == 77)
{
if (Map[c][d + 1].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c][d + 1].data = 2;
Map[c][d].data = 4;
d = d + 1;
Count--;
}
}
else if (Enter == 72)
{
if (Map[c - 1][d].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c - 1][d].data = 2;
Map[c][d].data = 4;
c = c - 1;
Count--;
}
}
else if (Enter == 80)
{
if (Map[c + 1][d].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c + 1][d].data = 2;
Map[c][d].data = 4;
c = c + 1;
Count--;
}
}
}
for (i = 1; i <= Map_Length; i++)
{
for (j = 1; j <= Map_Length; j++)
{
if (Map[i][j].data == 1)
{
cout << "■";
}
else if (Map[i][j].data == 0)
{
cout << " ";
}
else if (Map[i][j].data == 2)
{
cout << "鼠";
}
else if (Map[i][j].data == 3)
{
cout << "仓";
}
else if (Map[i][j].data == 4)
{
cout << " ";
}
}
cout << endl;
}
if (Map[Map_Length - 1][Map_Length - 1].data != 3)
{
system("cls");
cout << "闯关成功" << endl;
cout << "您的积分为" << Count << endl;
break;
}
}
}
}
void Player::KeepMap() //保存老鼠走过的路径
{
for (int i = 1; i <= Map_Length; i++)
{
for (int j = 1; j <= Map_Width; j++)
{
if (Map[i][j].data == 0)
{
cout << " ";
}
else if (Map[i][j].data == 1)
{
cout << "■";
}
else if (Map[i][j].data == 2)
{
cout << "鼠";
}
else if (Map[i][j].data == 3)
{
cout << "仓";
}
else if (Map[i][j].data == 4)
{
cout << "◇";
}
}
cout << endl;
}
}
void Player::show_Map() //编辑地图
{
int i, j;
//srand((unsigned)time(NULL)); //如果不适用随机数种子,那么每次程序启动生成的随机数(rand)都是一样的
GenerateMap(2 * (rand() % (Map_Length / 2 + 1)), 2 * (rand() % (Map_Width / 2 + 1)));
Map[Map_Length / 2][Map_Width / 2].data = 2; //初始化鼠 当二维数组的值为2时,代表鼠
Map[Map_Length - 1][Map_Width - 1].data = 3; //初始化仓 当二维数组的值为3时,代表仓
for (i = 1; i <= Map_Length; i++)
{
for (j = 1; j <= Map_Width; j++)
{
if (Map[i][j].data == 1)
{
cout << "■";
}
else if (Map[i][j].data == 0)
{
cout << " ";
}
else if (Map[i][j].data == 2)
{
cout << "鼠";
}
else if (Map[i][j].data == 3)
{
cout << "仓";
}
}
cout << endl;
}
}
void Player::Pre_Short()
{
rear = front = -1;
for (int i = 1; i <= Map_Length + 1; i++) //1-Map_Length才是想要的
{
for (int j = 1; j <= Map_Width + 1; j++)
{
if (i == 0 || i == Map_Length + 1 || j == 0 || j == Map_Width + 1)
{
Map[i][j].data = 0;
}
else
{
Map[i][j].data = 1;
}
}
}
for (int i = 0; i <= Map_Length; i++)
{
for (int j = 0; j < Map_Width; j++)
{
Map[i][j].visited = 0;
}
}
show_Map();
system("cls");
int m = Map_Length - 1, n = Map_Width - 1;
MapPoint p;
p.x = m, p.y = n, p.visited = 1;
p.data = 3;
ShortMap(p);
show();
while (top != -1)
{
top--;
}
}
void Player::EditorMap()
{
int c = Map_Length / 2;
int d = Map_Width / 2;
show_Map();
system("cls");
char Enter;
while (1)
{
for (int i = 1; i <= Map_Length; i++)
{
for (int j = 1; j <= Map_Length; j++)
{
if (Map[i][j].data == 1)
{
cout << "■";
}
else if (Map[i][j].data == 0)
{
cout << " ";
}
else if (Map[i][j].data == 2)
{
cout << "鼠";
}
else if (Map[i][j].data == 3)
{
cout << "仓";
}
else if (Map[i][j].data == 4)
{
cout << " ";
}
}
cout << endl;
}
cout << "输入回车键保存修改" << endl;
Enter = _getch();
system("cls");
if (Enter == -32)
{
Enter = _getch();
if (Enter == 75)
{
if (Map[c][d - 1].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c][d - 1].data = 2;
Map[c][d].data = 4;
d = d - 1;
}
}
else if (Enter == 77)
{
if (Map[c][d + 1].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c][d + 1].data = 2;
Map[c][d].data = 4;
d = d + 1;
}
}
else if (Enter == 72)
{
if (Map[c - 1][d].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c - 1][d].data = 2;
Map[c][d].data = 4;
c = c - 1;
}
}
else if (Enter == 80)
{
if (Map[c + 1][d].data == 1)
{
cout << "老鼠不能穿墙" << endl;
}
else
{
Map[c + 1][d].data = 2;
Map[c][d].data = 4;
c = c + 1;
}
}
}
if (Enter == 97)
{
if (Map[c][d - 1].data == 1)
{
Map[c][d - 1].data = 0;
}
else if (Map[c][d - 1].data == 0 || Map[c][d - 1].data == 4)
{
Map[c][d - 1].data = 1;
}
}
else if (Enter == 119)
{
if (Map[c - 1][d].data == 1)
{
Map[c - 1][d].data = 0;
}
else if (Map[c - 1][d].data == 0 || Map[c - 1][d].data == 4)
{
Map[c - 1][d].data = 1;
}
}
else if (Enter == 100)
{
if (Map[c][d + 1].data == 1)
{
Map[c][d + 1].data = 0;
}
else if (Map[c][d + 1].data == 0 || Map[c][d + 1].data == 4)
{
Map[c][d + 1].data = 1;
}
}
else if (Enter == 115)
{
if (Map[c + 1][d].data == 1)
{
Map[c + 1][d].data = 0;
}
else if (Map[c + 1][d].data == 0 || Map[c + 1][d].data == 4)
{
Map[c + 1][d].data = 1;
}
}
else if (Enter == 0x0D)
{
Map[c][d].data = 0;
break;
}
}
}
void Player::ShortMap(MapPoint& M)
{
M.visited = 1;
for (int i = 1; i <= Map_Length; i++)
{
for (int j = 1; j <= Map_Length; j++)
{
if (Map[i][j].data == 1)
{
cout << "■";
}
else if (Map[i][j].data == 0)
{
cout << " ";
}
else if (Map[i][j].data == 2)
{
cout << "鼠";
}
else if (Map[i][j].data == 3)
{
cout << "仓";
}
else if (Map[i][j].data == 4)
{
cout << " ";
}
}
cout << endl;
}
front = rear = -1;
rear++;
MpQueue[rear] = M;
int direc1[4][2] = { 1, 0, 0, 1, 0, -1, -1, 0 }; //d定义四个方向
while (front != rear)
{
front++;
for (int j = 0; j < 4; j++)
{
if ((Map[MpQueue[front].x + direc1[j][0]][MpQueue[front].y + direc1[j][1]].data == 0 || Map[MpQueue[front].x + direc1[j][0]][MpQueue[front].y + direc1[j][1]].data == 2 || Map[MpQueue[front].x + direc1[j][0]][MpQueue[front].y + direc1[j][1]].data == 4) && Map[MpQueue[front].x + direc1[j][0]][MpQueue[front].y + direc1[j][1]].visited == 0 && MpQueue[front].x < Map_Width && MpQueue[front].x >= 1 && MpQueue[front].y < Map_Length && MpQueue[front].y >= 1)
{
rear++;
MpQueue[rear].x = MpQueue[front].x + direc1[j][0];
MpQueue[rear].y = MpQueue[front].y + direc1[j][1];
Map[MpQueue[front].x + direc1[j][0]][MpQueue[front].y + direc1[j][1]].visited = 1;
if (MpQueue[rear].x == (Map_Length / 2) && MpQueue[rear].y == (Map_Width / 2))
{
flag = 1;
break;
}
}
}
if (flag == 1)
{
break;
}
}
Push();
}
void Player::GenerateMap(int x, int y)
{
int direction[4][2] = { 1,0,0,1,0,-1,-1,0 }; //定义方向
int i, j, temp;
for (i = 0; i < 4; i++) //打乱方向
{
j = rand() % 4; //随机选取方向
temp = direction[i][0];
direction[i][0] = direction[j][0];
direction[j][0] = temp;
temp = direction[i][1];
direction[i][1] = direction[j][1];
direction[j][1] = temp;
}
Map[x][y].data = 0;
for (i = 0; i < 4; i++) //任何两个空的地方都有路可走
{
if (Map[x + 2 * direction[i][0]][y + 2 * direction[i][1]].data == 1)
{
Map[x + direction[i][0]][y + direction[i][1]].data = 0; //打通墙
GenerateMap(x + 2 * direction[i][0], y + 2 * direction[i][1]);
}
}
}
Player::Player(int m, int n)
{
int i, j;
Map_Length = m, Map_Width = n;
for (i = 1; i <= Map_Length + 1; i++) //1-Map_Length才是想要的
{
for (j = 1; j <= Map_Width + 1; j++)
{
if (i == 0 || i == Map_Length + 1 || j == 0 || j == Map_Width + 1)
{
Map[i][j].data = 0;
}
else
{
Map[i][j].data = 1;
}
}
}
for (int i = 0; i < Size; i++)
{
for (int j = 0; j < Size; j++)
{
Map[i][j].visited = 0;
}
}
flag = 0;
front = rear = -1;
top = -1;
}
play.h:
#ifndef PLAY_H
#define PLAY_H
const int Size = 100;
struct MapPoint
{
int data;
int x, y; //保存路径的x与y坐标
int visited; //是否访问过的标签
};
class Player
{
private:
int top;
int flag;
int x, y;
int rear;
int front;
int Mouse_x, Mouse1_y; //老鼠的位置
int Map_Length, Map_Width;
MapPoint Mp[Size]; //栈
MapPoint MpQueue[230]; //队列
public:
Player(int m, int n);
void Push(); //入栈操作
void show();
void Move(); //老鼠移动
void KeepMap(); //保存路径
void PlayGame(); //开始游戏
void show_Map(); //显示地图
void Pre_Short();
void EditorMap(); //编辑地图
void ShortMap(MapPoint& M); //计算最短路径
void GenerateMap(int x, int y); //生成地图
MapPoint Map[Size][Size]; //地图数组
};
#endif
相关文章:
C/C++实现老鼠走迷宫
老鼠形象可以辨认,可以用上下左右操纵老鼠;正确检测结果,若老鼠在规定的时间内走到粮仓,提示成功,否则提示失败。代码分为3个文件:main.cpp、play.h、play.cpp。 main.cpp: #include <iostream> #include <…...

[Linux]文件基础-如何管理文件
回顾C语言之 - 文件如何被写入 fopen fwrite fread fclose fseek … 这一系列函数都是C语言中对文件进行的操作: int main() {FILE* fpfopen("text","w");char str[20]"write into text";fputs(str,fp);fclose(fp);return 0; }而上…...

bat 查找文件所在
脚本 在批处理文件(.bat)中查找文件所在的目录,你可以使用dir命令结合循环和条件语句来实现。以下是一个简单的示例,演示如何在批处理文件中查找指定文件并输出其所在目录: echo off setlocal enabledelayedexpansio…...
程序员的守护神:为何电脑永不熄灭?
在这个信息时代,程序员成了推动社会进步的“隐形英雄”。他们通宵达旦,手指在键盘上跳跃,创造出一个个令人惊叹的数字世界。有趣的是,你可能注意到了一个现象:程序员似乎总是不关电脑。这并非他们对电脑上瘾࿰…...

Kafka快速实战以及基本原理详解
Kafka快速实战以及基本原理详解 基本概念 Kafka是一个分布式、支持分区、多副本,基于ZK的分布式消息系统,最大的特性就是可以实时的处理大量数据以满足各种需求场景,比如Hadoop的批处理系统、低延迟的实时系统、Storm/Spark流式处理引擎、日…...
微信小程序(4)- 事件系统和模板语法
1. 事件系统 1.1 事件绑定和事件对象 小程序中绑定事件与在网页开发中绑定事件几乎一致,只不过在小程序不能通过 on 的方式绑定事件,也没有 click 等事件,小程序中绑定事件使用 bind 方法,click 事件也需要使用 tap 事件来进行代…...

【Java多线程】对线程池的理解并模拟实现线程池
目录 1、池 1.1、线程池 2、ThreadPoolExecutor 线程池类 3、Executors 工厂类 4、模拟实现线程池 1、池 “池”这个概念见到非常多,例如常量池、数据库连接池、线程池、进程池、内存池。 所谓“池”的概念就是:(提高效率) 1…...
python连接mysql数据库
连接MySQL数据库,通常我们会使用Python的mysql-connector-python库。下面是一个基本的示例来展示如何使用Python连接到MySQL数据库。 首先,确保你已经安装了mysql-connector-python库。如果没有,你可以使用pip来安装它: pip ins…...
docker用法
首先需要去docker官网注册你的账号,记住账号名称和密码; 然后在本地执行: docker login登录OK。 把ubuntu下载到本地: sudo docker pull ubuntusudo docker images输出: REPOSITORY TAG …...

DIcom调试Planar configuration
最近和CBCT组同事调dicom图像 这边得图像模块老不兼容对方得dicom文件。 vtk兼容,自己写得原生解析不兼容。 给对方调好了格式,下次生成文件还会有错。 简单记录下,日后备查。 今天对方又加了 个字段:Planar configuration 查…...

C#与VisionPro联合开发——跳转页面
1、跳转页面并打开相机 From1 所有代码展示 using System; using System.IO; using System.Windows.Forms; //引入VisionPro命名空间 using Cognex.VisionPro;namespace ConnectCamera {public partial class Form1 : Form {public Form1() {InitializeComponent();}CogAcqFif…...

服务端测试开发必备技能:Mock测试
什么是mock测试 Mock 测试就是在测试活动中,对于某些不容易构造或者不容易获取的数据/场景,用一个Mock对象来创建以便测试的测试方法。 Mock测试常见场景 无法控制第三方系统接口的返回,返回的数据不满足要求依赖的接口还未开发完成&#…...

vue3中ref创建变量取值时自动补充 .value 插件 volar
插件 TypeScript Vue Plugin (Volar) 设置中配置...
clickhouse的docker部署与springboot整合
注意:镜像bitnami/clickhouse包含服务端和客户端,yandex版本需要使用yandex/clickhouse-server,yandex/clickhouse-server docker启动命令(允许空密码 -e ALLOW_EMPTY_PASSWORD=yes),clickhouse版本不同,配置文件在的位置也会不一样/etc/clickhouse-server/config.xml d…...
Node.js_基础知识(计算机硬件基础)
主机的基本组成 CPU:Central Processing Unit,即中央处理器,是计算机的核心部件。是一块集成电路芯片,能够执行计算机指令并控制计算机的各种操作,负责运算和处理数据内存:是电脑硬件中的一块电路板,用于暂时存储CPU中的运算数据,是计算机与CPU进行沟通的桥梁,负责存储…...
git bash :download.sh: line 1: wget: command not found(已解决)
Windows中git bash完全可以替代原生的cmd,但是对于git bash会有一些Linux下广泛使用的命令的缺失,比如wget命令。 1、下载wget.exe,地址:https://eternallybored.org/misc/wget/ 2、将wget.exe 拷贝到C:\Program Files\Git\ming…...

BlackberryQ10 是可以安装 Android 4.3 应用的,Web UserAgent 版本信息
BlackberryQ10 是可以安装 Android 4.3 应用的 最近淘了个 Q10 手机,非常稀罕它,拿着手感一流。这么好的东西,就想给它装点东西,但目前所有的应用都已经抛弃这个安卓版本了。 一、开发环境介绍 BlackBerry Q10 的 安卓版本是 4.…...

JS前端高频面试
JS数据类型有哪些,区别是什么 js数据类型分为原始数据类型和引用数据类型。 原始数据类型包括:number,string,boolean,null,undefined,和es6新增的两种类型:bigint 和 symbol。&am…...

Flask数据库操作-Flask-SQLAlchemy
Flask中一般使用flask-sqlalchemy来操作数据库。flask-sqlalchemy的使用介绍如下: 一、SQLAlchemy SQLALchemy 实际上是对数据库的抽象,让开发者不用直接和 SQL 语句打交道,而是通过 Python 对象来操作数据库,在舍弃一些性能开销…...

H5获取手机相机或相册图片两种方式-Android通过webview传递多张照片给H5
需求目的: 手机机通过webView展示H5网页,在特殊场景下,需要使用相机拍照或者从相册获取照片,上传后台。 完整流程效果: 如下图 一、H5界面样例代码 使用html文件格式,文件直接打开就可以展示布局&#…...
【Linux】shell脚本忽略错误继续执行
在 shell 脚本中,可以使用 set -e 命令来设置脚本在遇到错误时退出执行。如果你希望脚本忽略错误并继续执行,可以在脚本开头添加 set e 命令来取消该设置。 举例1 #!/bin/bash# 取消 set -e 的设置 set e# 执行命令,并忽略错误 rm somefile…...

转转集团旗下首家二手多品类循环仓店“超级转转”开业
6月9日,国内领先的循环经济企业转转集团旗下首家二手多品类循环仓店“超级转转”正式开业。 转转集团创始人兼CEO黄炜、转转循环时尚发起人朱珠、转转集团COO兼红布林CEO胡伟琨、王府井集团副总裁祝捷等出席了开业剪彩仪式。 据「TMT星球」了解,“超级…...
macOS多出来了:Google云端硬盘、YouTube、表格、幻灯片、Gmail、Google文档等应用
文章目录 问题现象问题原因解决办法 问题现象 macOS启动台(Launchpad)多出来了:Google云端硬盘、YouTube、表格、幻灯片、Gmail、Google文档等应用。 问题原因 很明显,都是Google家的办公全家桶。这些应用并不是通过独立安装的…...

令牌桶 滑动窗口->限流 分布式信号量->限并发的原理 lua脚本分析介绍
文章目录 前言限流限制并发的实际理解限流令牌桶代码实现结果分析令牌桶lua的模拟实现原理总结: 滑动窗口代码实现结果分析lua脚本原理解析 限并发分布式信号量代码实现结果分析lua脚本实现原理 双注解去实现限流 并发结果分析: 实际业务去理解体会统一注…...
拉力测试cuda pytorch 把 4070显卡拉满
import torch import timedef stress_test_gpu(matrix_size16384, duration300):"""对GPU进行压力测试,通过持续的矩阵乘法来最大化GPU利用率参数:matrix_size: 矩阵维度大小,增大可提高计算复杂度duration: 测试持续时间(秒&…...
在鸿蒙HarmonyOS 5中使用DevEco Studio实现录音机应用
1. 项目配置与权限设置 1.1 配置module.json5 {"module": {"requestPermissions": [{"name": "ohos.permission.MICROPHONE","reason": "录音需要麦克风权限"},{"name": "ohos.permission.WRITE…...

在WSL2的Ubuntu镜像中安装Docker
Docker官网链接: https://docs.docker.com/engine/install/ubuntu/ 1、运行以下命令卸载所有冲突的软件包: for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done2、设置Docker…...

如何理解 IP 数据报中的 TTL?
目录 前言理解 前言 面试灵魂一问:说说对 IP 数据报中 TTL 的理解?我们都知道,IP 数据报由首部和数据两部分组成,首部又分为两部分:固定部分和可变部分,共占 20 字节,而即将讨论的 TTL 就位于首…...

基于 TAPD 进行项目管理
起因 自己写了个小工具,仓库用的Github。之前在用markdown进行需求管理,现在随着功能的增加,感觉有点难以管理了,所以用TAPD这个工具进行需求、Bug管理。 操作流程 注册 TAPD,需要提供一个企业名新建一个项目&#…...

人机融合智能 | “人智交互”跨学科新领域
本文系统地提出基于“以人为中心AI(HCAI)”理念的人-人工智能交互(人智交互)这一跨学科新领域及框架,定义人智交互领域的理念、基本理论和关键问题、方法、开发流程和参与团队等,阐述提出人智交互新领域的意义。然后,提出人智交互研究的三种新范式取向以及它们的意义。最后,总结…...