当前位置: 首页 > news >正文

C语言之装甲车库车辆动态监控辅助记录系统


🌟 嗨,我是LucianaiB!

🌍 总有人间一两风,填我十万八千梦。

🚀 路漫漫其修远兮,吾将上下而求索。


C语言之装甲车库车辆动态监控辅助记录系统

目录

  1. 一、前言
    1.1 (一)问题描述
    1.2 (二)算法输入
  2. 二、算法要点描述与实现思想
    2.1 (一)算法要点
    2.2 (二)实现思想
    2.2.1 1、输入处理模块
    2.2.2 2、装甲车库初始化模块
    2.2.3 3、主菜单控制模块
    2.2.4 4、装甲车入场模块
    2.2.5 5、装甲车出场模块
    2.2.6 6、装甲车状态显示模块
    2.2.7 7、装甲车搜索模块
    2.2.8 8、油量冒泡排序
    2.2.9 9、损坏程度快速排序
  3. 三、数据结构确定和数据类型ADT定义
  4. 四、主要算法程序框图
  5. 五、测试数据及结果分析(含时间、空间复杂度分析)
    5.1 (一)时间复杂度
    5.2 (二)空间复杂度
  6. 六、设计体会,存在问题及分析
    6.1 (一)存在问题
    6.2 (二)遇到困难
    6.3 (三)修改与完善
  7. 附录代码

一、前言

(一)问题描述

设计一个狭长通道装甲车库车辆动态监控辅助记录系统的管理程序,实现装甲车默认按先后顺序停放,也可以自选位置停放、出场时让装甲车按车牌号离开车库的功能。
在这里插入图片描述
在这里插入图片描述

(二)算法输入

装甲车入场:
用户选择菜单中的“1. 装甲车辆入场”功能。
输入车牌号 MD521,输入油量百分比:85,输入损坏程度百分比:30,选择停车位 (1-100):4,系统成功将车辆停放在第4个空闲位置。
系统提示“车辆 MU521 已停入主装甲车库,位置:4”,显示车辆成功入场。
在这里插入图片描述

装甲车辆出场:
用户选择菜单中的“2. 装甲车辆出场”功能。
输入要移出的车牌号 MU521,系统成功从停车场移除该车辆。
系统提示“装甲车 MU521 离开主装甲车库,停车时长:0.04 小时”,显示车辆成功出场,并输出停车时长。
在这里插入图片描述

装甲车库状态显示:
用户选择菜单中的“3. 显示装甲车库状态”功能。
系统打印所有 100 个装甲车库的状态,显示99个装甲车库当前状态为空闲(未停放车辆),一个装甲车,并打印信息。
系统统计装甲车库信息:总容量:100,当前数量:1。位置 4: MU521 (油量: 85%, 损坏: 30%)
在这里插入图片描述

搜索装甲车失败:
用户选择菜单中的“4. 按照装甲车牌号查询车辆”功能。
输入车牌号 999,系统未能找到该装甲车库,提示“未找到车牌号为 999 的车辆”。
说明装甲车可能已出场或未入场。
在这里插入图片描述

车辆成功搜索:
用户选择菜单中的“4. 搜索车辆”功能,输入车牌号 MU521,系统成功定位车辆,提示“找到装甲车 MU521,位置 4,油量 85%,损坏程度 30%”。
在这里插入图片描述

装甲车油量排序:
用户选择菜单中的“5. 查询装甲车辆油量并按油量排序”功能,按照冒泡排序从油量大到小进行排序并输出。
在这里插入图片描述

装甲车损坏程度排序:
用户选择菜单中的“6. 查询装甲车辆装备损坏情况并按损坏程度排序”功能,按照快速排序从损坏程度小到大进行排序并输出。

在这里插入图片描述

二、算法要点描述与实现思想

(一)算法要点

  1. 装甲车库创建模块:
    o 使用 createGarage 函数初始化装甲车库,分配内存并设置初始状态,包括前驱和后继指针、容量、大小以及占用状态数组。
  2. 装甲车库状态检查模块:
    o isFull 函数检查装甲车库是否已满,即当前数量是否达到最大容量。
    o isEmpty 函数检查装甲车库是否为空,即当前数量是否为零。
  3. 装甲车辆入场模块:
    o enterGarage 函数处理装甲车辆的入场,包括用户选择停车位、输入车辆信息,并将其添加到链表中相应的位置。
    o 如果主装甲车库未满,将车辆信息添加到主车库的链表中,并更新占用状态。
    o 如果主装甲车库已满,将车辆信息添加到临时车库的链表中。
  4. 装甲车辆出场模块:
    o leaveGarage 函数处理装甲车辆的出场,遍历主装甲车库的链表找到对应车辆,并更新链表和占用状态。
    o 如果临时车库有车辆,将临时车库中的第一辆车移动到主车库中空出的位置上。
  5. 装甲车库状态显示模块:
    o displayStatus 函数显示主装甲车库和临时车库的当前状态,包括每个车位的车辆信息和空位。
  6. 装甲车辆搜索模块:
    o searchVehicle 函数根据车牌号搜索车辆,遍历主装甲车库的链表,找到对应车辆后显示其信息。
  7. 装甲车辆油量显示模块:
    o displayFuelLevels 函数显示主装甲车库中所有车辆的油量信息,并按油量进行冒泡排序。
  8. 装甲车辆损坏程度显示模块:
    o displayDamageLevels 函数显示主装甲车库中所有车辆的损坏程度信息,并使用快速排序算法按损坏程度排序。
  9. 数据持久化模块:
    o saveState 和 loadState 函数分别用于保存和加载装甲车库的状态,包括车辆信息和占用状态。
  10. 主控菜单模块:
    o 程序通过无限循环显示菜单,接收用户的选择,并根据选择调用相应的功能函数。

(二)实现思想

1、输入处理模块

该模块负责接收用户输入的功能选项和装甲车牌号,并对这些输入数据进行处理。
实现思想:
主菜单通过提示用户输入功能编号,并使用 scanf 获取用户输入。 在处理特定功能时,如装甲车辆入场或出场,处理车牌号的输入并检查其合法性,确保车牌号不超出预设的最大长度 MAX_PLATE_LEN。

printf("请输入您的选择: ");
if (scanf("%d", &choice) != 1) {printf("输入无效,请输入数字。\n");// 清除输入缓冲区while (getchar() != '\n');continue;
}printf("请输入装甲车牌号: ");
scanf("%s", licensePlate);
if (strlen(licensePlate) >= MAX_PLATE_LEN) {printf("车牌号过长,请输入不超过%d个字符的车牌号。\n", MAX_PLATE_LEN - 1);// 清除输入缓冲区while (getchar() != '\n');continue;
}

2、装甲车库初始化模块

该模块负责在程序启动时将装甲车库的所有车位初始化为空闲状态,并清空车牌号信息。
实现思想:
通过循环遍历所有装甲车库,将每个装甲车库的占用状态设置为未占用(0),并将车牌号信息清空。

void initializeParking(ParkingSpot parking[], int numSpots) {     int i;     for (i = 0; i < numSpots; i++) {         parking[i].isOccupied = false; // 设置为未占用         memset(parking[i].licensePlate, 0, sizeof(parking[i].licensePlate)); // 清空车牌号     } 
}

3、主菜单控制模块

该模块负责显示主菜单,接收用户输入,并根据用户的选择调用相应的功能函数。
实现思想:
使用 while 循环不断显示主菜单,接受用户的选择。 使用 switch 语句根据用户输入调用具体的功能函数。 提供退出选项(当 choice 等于7时),终止循环并退出程序。

 int main() {int choice;char plate[MAX_PLATE_LEN];int fuelLevel, damageLevel, garageCapacity;mainGarage = createGarage(0);tempGarage = createGarage(100);loadState();if (mainGarage->capacity == 0) {printf("请输入主装甲车库容量:");scanf("%d", &garageCapacity);mainGarage->capacity = garageCapacity;}while (1) {displayMenu();scanf("%d", &choice);switch (choice) {case 1:printf("请输入车牌号:");scanf("%s", plate);printf("请输入油量百分比:");scanf("%d", &fuelLevel);printf("请输入损坏程度百分比:");scanf("%d", &damageLevel);enterGarage(plate, fuelLevel, damageLevel);break;case 2:printf("请输入车牌号:");scanf("%s", plate);leaveGarage(plate);break;case 3:displayStatus();break;case 4:printf("请输入要查找的车牌号:");scanf("%s", plate);searchVehicle(plate);break;case 5:displayFuelLevels();break;case 6:displayDamageLevels();break;case 7:saveState();printf("系统已保存,感谢使用!\n");free(mainGarage);free(tempGarage);return 0;default:printf("无效选择,请重试\n");}}return 0;
}

4、装甲车入场模块

该模块负责将新入场的装甲车停放在第一个可用的停车位上,并更新停车位的状态。
实现思想:
遍历装甲车库的停车位数组,找到第一个未被占用的停车位。 将用户输入的装甲车牌号存储到该停车位,并将其状态设置为已占用。 如果装甲车库已满,即没有找到空闲停车位,提示用户无法停放车辆。

void enterGarage(char* plate, int fuelLevel, int damageLevel) {Node* newNode = (Node*)malloc(sizeof(Node));if (newNode == NULL) {perror("Memory allocation failed");return;}strcpy(newNode->vehicle.plate, plate);newNode->vehicle.arriveTime = time(NULL);newNode->vehicle.fuelLevel = fuelLevel;newNode->vehicle.damageLevel = damageLevel;newNode->next = NULL;if (!isFull(mainGarage)) {int position;printf("请选择停装甲车位 (1-%d): ", mainGarage->capacity);scanf("%d", &position);// Input validation and error handlingwhile (position < 1 || position > mainGarage->capacity || mainGarage->occupied[position - 1]) {printf("无效的装甲车位选择,该位置已被占用或超出范围。请重新选择 (1-%d): ", mainGarage->capacity);scanf("%d", &position);}mainGarage->occupied[position - 1] = true;// Corrected linked list insertionNode* current = mainGarage->front;Node* prev = NULL;int i = 1;while (current != NULL && i < position) {prev = current;current = current->next;i++;}newNode->next = current;if (prev == NULL) {mainGarage->front = newNode;} else {prev->next = newNode;}if (current == NULL) {mainGarage->rear = newNode;}mainGarage->size++;printf("装甲车 %s 已停入主装甲车库,位置:%d\n", plate, position);} else {printf("主装甲车库已满,无法停放更多装甲车。\n");}
}

5、装甲车出场模块

该模块负责根据用户输入的车牌号找到对应的装甲车,将其从停车位上移除,并将停车位状态设置为空闲。
实现思想:
遍历装甲车库的停车位数组,找到车牌号匹配的停车位。 将匹配到的停车位状态设置为未占用,并清空车牌号。 如果未找到匹配的车牌号,提示用户车辆未找到。

void leaveGarage(char* plate) {Node* current = mainGarage->front;Node* prev = NULL;while (current != NULL) {if (strcmp(current->vehicle.plate, plate) == 0) {if (prev == NULL) {mainGarage->front = current->next;if (mainGarage->front == NULL) {mainGarage->rear = NULL;}} else {prev->next = current->next;if (current->next == NULL) {mainGarage->rear = prev;}}printf("装甲车 %s 离开主装甲车库,停车时长:%.2f 小时\n", plate, difftime(time(NULL), current->vehicle.arriveTime) / 3600.0);free(current);mainGarage->size--;// Check if there are any vehicles in the tempGarage to move to mainGarageif (!isEmpty(tempGarage)) {Node* tempCar = tempGarage->front;tempGarage->front = tempGarage->front->next;tempGarage->size--;tempCar->next = NULL;if (isEmpty(mainGarage)) {mainGarage->front = mainGarage->rear = tempCar;} else {mainGarage->rear->next = tempCar;mainGarage->rear = tempCar;}mainGarage->size++;printf("便道第一辆装甲车 %s 已进入主装甲车库\n", tempCar->vehicle.plate);}return;}prev = current;current = current->next;}printf("未找到装甲车牌号为 %s 的装甲车。\n", plate);
}

6、装甲车状态显示模块

该模块负责显示装甲车库中每个停车位的状态,包括是否被占用以及对应的车牌号,并统计显示占用和空闲的停车位数量。 实现思想:
遍历装甲车库的停车位数组,检查每个停车位的状态。 对于每个停车位,输出其位置编号、是否被占用以及车牌号信息。 同时统计已占用和空闲的停车位数量,并在最后显示这些统计信息。

void displayStatus() {printf("\n=== 主装甲车库状态 ===\n");printf("总容量:%d,当前数量:%d\n", mainGarage->capacity, mainGarage->size);Node* current = mainGarage->front; // Start at the beginning of the linked listint vehicleIndex = 0;             // Index to track the current vehicle in the listfor (int i = 0; i < mainGarage->capacity; ++i) {if (mainGarage->occupied[i]) {if (vehicleIndex < mainGarage->size) { // Check if there's a vehicle to displayprintf("位置 %d: %s (油量: %d%%, 损坏: %d%%)\n", i + 1, current->vehicle.plate, current->vehicle.fuelLevel, current->vehicle.damageLevel);current = current->next; // Move to the next vehicle in the listvehicleIndex++;}} else {printf("位置 %d: 空\n", i + 1);}}printf("\n=== 临时便道状态 ===\n");printf("当前等待数量:%d\n", tempGarage->size);current = tempGarage->front;int position = 1;while (current != NULL) {printf("等待位置 %d: %s\n", position++, current->vehicle.plate);current = current->next;}
}

7、装甲车搜索模块

该模块负责根据用户输入的车牌号在装甲车库中搜索对应的车辆,并返回车辆所在的位置或者提示车辆未找到。 实现思想:
遍历装甲车库的停车位数组,查找与输入车牌号匹配的停车位。 如果找到匹配的车牌号,返回该车辆的停车位编号。 如果遍历完成后未找到匹配的车牌号,提示用户车辆未找到。

void searchVehicle(char* plate) {Node* current = mainGarage->front;int position = 0;while (current != NULL) {position++;if (strcmp(current->vehicle.plate, plate) == 0) {// Find the actual parking spot using occupied arrayint parkingSpot = 0;for (int i = 0; i < mainGarage->capacity; ++i) {if (mainGarage->occupied[i]) {parkingSpot++;if (parkingSpot == position) {printf("找到装甲车 %s,位置 %d,油量 %d%%,损坏程度 %d%%\n", plate, i + 1, current->vehicle.fuelLevel, current->vehicle.damageLevel);return;}}}return; //Should not reach here, but added for safety}current = current->next;}printf("未找到装甲车牌号为 %s 的装甲车。\n", plate);
}

8、油量冒泡排序

该模块负责显示主装甲车库中所有装甲车的油量,并按油量从低到高进行冒泡排序。
实现思想:
遍历主装甲车库的链表,收集所有装甲车的油量信息。 使用排序算法(冒泡排序)对油量信息进行排序。 显示排序后的油量信息及对应装甲车的车牌号和位置。

void displayFuelLevels() {Node* current = mainGarage->front;int numVehicles = mainGarage->size; // Directly use the size of the garageif (numVehicles == 0) {printf("装甲车为空\n");return;}// 创建一个数组来存储车辆节点指针和它们的位置Node* vehicles[numVehicles];int positions[numVehicles];int i = 0;// 遍历链表填充数组while (current != NULL) {vehicles[i] = current;// 找到车辆在占用数组中的位置int pos = 0;for (int j = 0; j < mainGarage->capacity; j++) {if (mainGarage->occupied[j]) {pos++;if (pos == i + 1) {positions[i] = j + 1;break;}}}current = current->next;i++;}// 冒泡排序,根据油量排序for (int i = 0; i < numVehicles - 1; i++) {for (int j = 0; j < numVehicles - i - 1; j++) {if (vehicles[j]->vehicle.fuelLevel > vehicles[j + 1]->vehicle.fuelLevel) {// 交换节点Node* temp = vehicles[j];vehicles[j] = vehicles[j + 1];vehicles[j + 1] = temp;// 交换位置int tempPos = positions[j];positions[j] = positions[j + 1];positions[j + 1] = tempPos;}}}// 显示排序结果printf("\n=== 按油量排序(冒泡排序) ===\n");for (int i = 0; i < numVehicles; i++) {printf("装甲车 %s: 油量 %d%%, 停车位 %d\n", vehicles[i]->vehicle.plate, vehicles[i]->vehicle.fuelLevel, positions[i]);}
}

9、损坏程度快速排序

该模块负责显示主装甲车库中所有装甲车的损坏程度,并按损坏程度从低到高进行排序。
实现思想:
遍历主装甲车库的链表,收集所有装甲车的损坏程度信息。 使用排序算法(快速排序)对损坏程度信息进行排序。 显示排序后的损坏程度信息及对应装甲车的车牌号和位置。

void displayDamageLevels() {Node* current = mainGarage->front;int numVehicles = mainGarage->size;if (numVehicles == 0) {printf("装甲车库为空\n");return;}// 创建一个数组来存储车辆节点指针和它们的位置Node* vehicles[numVehicles];int positions[numVehicles];int i = 0;// 遍历链表填充数组while (current != NULL) {vehicles[i] = current;int pos = 0;for (int j = 0; j < mainGarage->capacity; j++) {if (mainGarage->occupied[j]) {pos++;if (pos == i + 1) {positions[i] = j + 1;break;}}}current = current->next;i++;}// 快速排序,根据损坏程度排序quickSort(vehicles, positions, 0, numVehicles - 1);// 显示排序结果printf("\n=== 按损坏程度排序(快速排序) ===\n");for (int i = 0; i < numVehicles; i++) {printf("装甲车 %s: 损坏程度 %d%%, 停车位 %d\n", vehicles[i]->vehicle.plate, vehicles[i]->vehicle.damageLevel, positions[i]);}
}// 快速排序的分区函数
int partition(Node* vehicles[], int positions[], int low, int high) {int pivot = vehicles[high]->vehicle.damageLevel;int i = low - 1;for (int j = low; j <= high - 1; j++) {if (vehicles[j]->vehicle.damageLevel <= pivot) {i++;Node* temp = vehicles[i];vehicles[i] = vehicles[j];vehicles[j] = temp;int tempPos = positions[i];positions[i] = positions[j];positions[j] = tempPos;}}Node* temp = vehicles[i + 1];vehicles[i + 1] = vehicles[high];vehicles[high] = temp;int tempPos = positions[i + 1];positions[i + 1] = positions[high];positions[high] = tempPos;return i + 1;
}// 快速排序函数
void quickSort(Node* vehicles[], int positions[], int low, int high) {if (low < high) {int pivotIndex = partition(vehicles, positions, low, high);quickSort(vehicles, positions, low, pivotIndex - 1);quickSort(vehicles, positions, pivotIndex + 1, high);}
} 

三、数据结构确定和数据类型ADT定义

本程序采用了结构体和数组的数据结构,用于管理装甲车库状态和装甲车信息。具体地,定义了以下数据类型:

// Vehicle 结构体: 用于存储单个装甲车的车辆信息。
typedef struct {char plate[MAX_PLATE_LEN];  // 车牌号time_t arriveTime;          // 到达时间int fuelLevel;              // 油量百分比int damageLevel;            // 损坏程度百分比
} Vehicle;
// Node 结构体: 用于创建链表节点,表示装甲车库中的每个停车位。
typedef struct Node {Vehicle vehicle;           // 装甲车信息struct Node* next;        // 指向下一个节点的指针
} Node;
// Garage 结构体:用于管理整个装甲车库,包括链表头节点、尾节点、容量、当前装甲车数量以及停车位占用状态数组。
typedef struct {Node* front;              // 链表头节点Node* rear;               // 链表尾节点int capacity;             // 最大容量int size;                 // 当前装甲车数量bool* occupied;           // 停车位占用状态数组
} Garage; 

四、主要算法程序框图

程序流程图如下图

在这里插入图片描述

• 开始后,系统显示主菜单。
• 用户根据菜单选择不同的操作:
o 选择1,输入装甲车的车牌号、油量和损坏程度,将装甲车停入主车库。
o 选择2,输入车牌号,从主车库移除装甲车。
o 选择3,显示车库的当前状态。
o 选择4,输入要查找的车牌号,搜索装甲车。
o 选择5,按油量排序显示装甲车信息。
o 选择6,按损坏程度排序显示装甲车信息。
o 选择7,保存车库状态并退出系统。
• 系统结束。

五、测试数据及结果分析(含时间、空间复杂度分析)

(一)时间复杂度

时间复杂度分析

  1. 主函数 main()
    时间复杂度:O(k),其中 k 为用户选择功能的次数。
    说明:主函数中的 while 循环会根据用户的选择执行不同的操作,每次操作的时间复杂度取决于具体的函数实现,但整体复杂度与用户操作次数成正比。
  2. 初始化车库 createGarage()
    时间复杂度:O(1)。
    说明:该函数执行固定数量的操作来初始化车库,与车库的大小无关。
  3. 检查车库状态
    isFull() 和 isEmpty()
    时间复杂度:O(1)。
    说明:这两个函数仅涉及简单的比较操作,时间复杂度为常数。
  4. 装甲车入场 enterGarage()
    时间复杂度:O(n),其中 n 为车库容量。
    说明:在最坏情况下,可能需要遍历整个车库来找到空闲位置或验证用户选择的位置。
  5. 装甲车出场 leaveGarage()
    时间复杂度:O(n),其中 n 为车库容量。
    说明:在最坏情况下,需要遍历整个车库链表来找到并移除指定的装甲车。
  6. 显示车库状态 displayStatus()
    时间复杂度:O(n),其中 n 为车库容量。
    说明:该函数需要遍历车库中的每个停车位来显示其状态。
  7. 搜索车辆 searchVehicle()
    时间复杂度:O(n),其中 n 为车库容量。
    说明:在最坏情况下,需要遍历整个车库链表来查找指定的装甲车。
  8. 显示油量和损坏程度排序
    displayFuelLevels() 和 displayDamageLevels()
    时间复杂度:O(n^2),其中 n 为车库容量。
    说明:这两个函数需要对所有装甲车进行排序,使用了冒泡排序或快速排序算法。快速排序的平均时间复杂度为 O(n log n),但在最坏情况下为 O(n^2)。
  9. 数据持久化
    saveState() 和 loadState()
    时间复杂度:O(n),其中 n 为车库容量。
    说明:这两个函数需要遍历车库中的每个装甲车来保存或加载状态。

(二)空间复杂度

空间复杂度分析

  1. 初始化车库 createGarage()
    空间复杂度:O(n),其中 n 为车库容量。
    说明:需要为 occupied 数组分配空间,其大小与车库容量成正比。
  2. 装甲车入场 enterGarage() 和 装甲车出场 leaveGarage()
    空间复杂度:O(1)。
    说明:除了输入参数外,不需要额外的空间与车库大小成比例。
  3. 显示车库状态 displayStatus()、搜索车辆 searchVehicle()、显示油量排序 displayFuelLevels() 和 显示损坏程度排序 displayDamageLevels()
    空间复杂度:O(n),其中 n 为车库容量。
    说明:这些函数可能需要额外的数组来存储装甲车信息或进行排序,其大小与车库容量成正比。
  4. 数据持久化 saveState() 和 loadState()
    空间复杂度:O(n),其中 n 为车库容量。
    说明:需要为保存或加载的装甲车信息分配空间。

六、设计体会,存在问题及分析

(一)存在问题

车库容量的动态调整问题: 当前系统通过宏定义固定车库容量,缺乏灵活性。在实际应用中,可能需要根据实际情况动态调整车库容量。
数据持久化缺失: 系统关闭后,所有装甲车信息丢失,无法恢复。这对于需要长期运行的管理系统来说是一大缺陷。
搜索效率问题: 在大规模车库中,线性搜索效率低下,影响系统性能。
输入处理机制不足: 系统对用户输入的错误处理较为简单,缺乏智能纠错机制。

(二)遇到困难

功能模块逻辑设计: 设计车辆入场、出场和搜索功能时,需要确保逻辑的一致性和准确性,避免车位的重复分配或错误释放。
输入合法性验证: 处理用户输入时,需要确保输入的合法性,防止非法输入导致程序崩溃。
状态显示布局: 在有限的屏幕空间中清晰地展示大量停车位信息是一个设计挑战。
时间复杂度优化: 平衡代码的简单性和性能优化是一个难点,尤其是在大规模数据集上。

(三)修改与完善

动态调整车库容量: 可以考虑使用动态数据结构,如动态数组或链表,来管理停车位,以便根据需要调整车库容量。
实现数据持久化: 通过文件系统或数据库来保存装甲车信息,即使系统关闭也能恢复数据。
优化搜索算法: 引入更高效的搜索算法,如哈希表或二分搜索,以提高大规模数据集的搜索效率。
增强输入处理: 实现更智能的输入验证和错误处理机制,提供用户友好的反馈和纠错建议。

附录代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>#define MAX_PLATE_LEN 20
#define SAVE_FILE "garage_state.txt"// 车辆信息结构体
typedef struct {char plate[MAX_PLATE_LEN];  // 车牌号time_t arriveTime;          // 到达时间int fuelLevel;             // 油量百分比int damageLevel;           // 损坏程度百分比
} Vehicle;// 装甲车库节点结构体
typedef struct Node {Vehicle vehicle;struct Node* next;
} Node;// 装甲车库队列结构体
typedef struct {Node* front;Node* rear;int capacity;    // 最大容量int size;        // 当前数量bool* occupied; // 停车位占用状态数组
} Garage;Garage* mainGarage;
Garage* tempGarage;Garage* createGarage(int capacity);
int isFull(Garage* garage);
int isEmpty(Garage* garage);
void enterGarage(char* plate, int fuelLevel, int damageLevel);
void leaveGarage(char* plate);
void displayStatus();
void searchVehicle(char* plate);
void displayFuelLevels();
void displayDamageLevels();
void displayMenu();
void saveState();
void loadState();Garage* createGarage(int capacity) {Garage* garage = (Garage*)malloc(sizeof(Garage));if (garage == NULL) {perror("Memory allocation failed for garage");exit(1); // Exit with an error code}garage->front = garage->rear = NULL;garage->capacity = capacity;garage->size = 0;garage->occupied = (bool*)calloc(capacity, sizeof(bool)); // Allocate memory for occupied arrayif (garage->occupied == NULL) {perror("Memory allocation failed for occupied array");free(garage); // Free the garage memory since allocation failedexit(1); // Exit with an error code}return garage;
}int isFull(Garage* garage) {return garage->size >= garage->capacity;
}int isEmpty(Garage* garage) {return garage->size == 0;
}void enterGarage(char* plate, int fuelLevel, int damageLevel) {Node* newNode = (Node*)malloc(sizeof(Node));if (newNode == NULL) {perror("Memory allocation failed");return;}strcpy(newNode->vehicle.plate, plate);newNode->vehicle.arriveTime = time(NULL);newNode->vehicle.fuelLevel = fuelLevel;newNode->vehicle.damageLevel = damageLevel;newNode->next = NULL;if (!isFull(mainGarage)) {int position;printf("请选择停装甲车位 (1-%d): ", mainGarage->capacity);scanf("%d", &position);// Input validation and error handlingwhile (position < 1 || position > mainGarage->capacity || mainGarage->occupied[position - 1]) {printf("无效的装甲车位选择,该位置已被占用或超出范围。请重新选择 (1-%d): ", mainGarage->capacity);scanf("%d", &position);}mainGarage->occupied[position - 1] = true;// Corrected linked list insertionNode* current = mainGarage->front;Node* prev = NULL;int i = 1;while (current != NULL && i < position) {prev = current;current = current->next;i++;}newNode->next = current;if (prev == NULL) {mainGarage->front = newNode;} else {prev->next = newNode;}if (current == NULL) {mainGarage->rear = newNode;}mainGarage->size++;printf("装甲车 %s 已停入主装甲车库,位置:%d\n", plate, position);} else {// 临时车位处理if (isEmpty(tempGarage)) {tempGarage->front = tempGarage->rear = newNode;} else {tempGarage->rear->next = newNode;tempGarage->rear = newNode;}tempGarage->size++;printf("主装甲车库已满,装甲车车辆 %s 已停入临时便道,位置:%d\n", plate, tempGarage->size);}
}void leaveGarage(char* plate) {Node* current = mainGarage->front;Node* prev = NULL;while (current != NULL) {if (strcmp(current->vehicle.plate, plate) == 0) {if (prev == NULL) {mainGarage->front = current->next;if (mainGarage->front == NULL) {mainGarage->rear = NULL;}} else {prev->next = current->next;if (current->next == NULL) {mainGarage->rear = prev;}}printf("装甲车 %s 离开主装甲车库,停车时长:%.2f 小时\n", plate, difftime(time(NULL), current->vehicle.arriveTime) / 3600.0);free(current);mainGarage->size--;if (!isEmpty(tempGarage)) {Node* tempCar = tempGarage->front;tempGarage->front = tempGarage->front->next;tempGarage->size--;tempCar->next = NULL;if (isEmpty(mainGarage)) {mainGarage->front = mainGarage->rear = tempCar;} else {mainGarage->rear->next = tempCar;mainGarage->rear = tempCar;}mainGarage->size++;printf("便道第一辆装甲车 %s 已进入主装甲车库\n", tempCar->vehicle.plate);}return;}prev = current;current = current->next;}printf("未找到装甲车 %s\n", plate);
}void displayFuelLevels() {Node* current = mainGarage->front;int numVehicles = mainGarage->size; // Directly use the size of the garageif (numVehicles == 0) {printf("装甲车为空\n");return;}Node* vehicles[numVehicles];int positions[numVehicles];int i = 0;// Correctly iterate through the linked list to populate the arrayswhile (current != NULL) {vehicles[i] = current;// Find the position of the vehicle in the occupied arrayint pos = 0;for (int j = 0; j < mainGarage->capacity; j++) {if (mainGarage->occupied[j]) {pos++;if (pos == i + 1) {positions[i] = j + 1;break;}}}current = current->next;i++;}// 冒泡排序for (int i = 0; i < numVehicles - 1; i++) {for (int j = 0; j < numVehicles - i - 1; j++) {if (vehicles[j]->vehicle.fuelLevel < vehicles[j + 1]->vehicle.fuelLevel) {Node* temp = vehicles[j];vehicles[j] = vehicles[j + 1];vehicles[j + 1] = temp;int tempPos = positions[j];positions[j] = positions[j + 1];positions[j + 1] = tempPos;}}}printf("\n=== 按油量排序(冒泡排序) ===\n");for (int i = 0; i < numVehicles; i++) {printf("装甲车 %s: 油量 %d%%, 停车位 %d\n", vehicles[i]->vehicle.plate, vehicles[i]->vehicle.fuelLevel, positions[i]);}
}// 快速排序
int partition(Node* vehicles[], int positions[], int low, int high) {int pivot = vehicles[high]->vehicle.damageLevel;int i = low - 1;for (int j = low; j <= high - 1; j++) {if (vehicles[j]->vehicle.damageLevel <= pivot) {i++;Node* temp = vehicles[i];vehicles[i] = vehicles[j];vehicles[j] = temp;int tempPos = positions[i];positions[i] = positions[j];positions[j] = tempPos;}}Node* temp = vehicles[i + 1];vehicles[i + 1] = vehicles[high];vehicles[high] = temp;int tempPos = positions[i + 1];positions[i + 1] = positions[high];positions[high] = tempPos;return i + 1;
}void quickSort(Node* vehicles[], int positions[], int low, int high) {if (low < high) {int pivotIndex = partition(vehicles, positions, low, high);quickSort(vehicles, positions, low, pivotIndex - 1);quickSort(vehicles, positions, pivotIndex + 1, high);}
}void displayDamageLevels() {Node* current = mainGarage->front;int numVehicles = mainGarage->size;if (numVehicles == 0) {printf("装甲车库为空\n");return;}Node* vehicles[numVehicles];int positions[numVehicles];int i = 0;while (current != NULL) {vehicles[i] = current;int pos = 0;for (int j = 0; j < mainGarage->capacity; j++) {if (mainGarage->occupied[j]) {pos++;if (pos == i + 1) {positions[i] = j + 1;break;}}}current = current->next;i++;}quickSort(vehicles, positions, 0, numVehicles - 1);printf("\n=== 按损坏程度排序(快速排序) ===\n");for (int i = 0; i < numVehicles; i++) {printf("装甲车 %s: 损坏程度 %d%%, 停车位 %d\n", vehicles[i]->vehicle.plate, vehicles[i]->vehicle.damageLevel, positions[i]);}
}void displayStatus() {printf("\n=== 主装甲车库状态 ===\n");printf("总容量:%d,当前数量:%d\n", mainGarage->capacity, mainGarage->size);Node* current = mainGarage->front; // Start at the beginning of the linked listint vehicleIndex = 0;             // Index to track the current vehicle in the listfor (int i = 0; i < mainGarage->capacity; ++i) {if (mainGarage->occupied[i]) {if (vehicleIndex < mainGarage->size) { // Check if there's a vehicle to displayprintf("位置 %d: %s (油量: %d%%, 损坏: %d%%)\n", i + 1, current->vehicle.plate, current->vehicle.fuelLevel, current->vehicle.damageLevel);current = current->next; // Move to the next vehicle in the listvehicleIndex++;}} else {printf("位置 %d: 空\n", i + 1);}}printf("\n=== 临时便道状态 ===\n");printf("当前等待数量:%d\n", tempGarage->size);current = tempGarage->front;int position = 1;while (current != NULL) {printf("等待位置 %d: %s\n", position++, current->vehicle.plate);current = current->next;}
}void loadState() {FILE* file = fopen(SAVE_FILE, "r");if (!file) {printf("未找到保存文件,将初始化系统。\n");return;}fscanf(file, "%d", &mainGarage->capacity);mainGarage->size = 0;mainGarage->front = mainGarage->rear = NULL;char plate[MAX_PLATE_LEN];int fuelLevel, damageLevel;time_t arriveTime;while (fscanf(file, "%s %ld %d %d", plate, &arriveTime, &fuelLevel, &damageLevel) == 4) {enterGarage(plate, fuelLevel, damageLevel);}fclose(file);printf("系统状态已加载。\n");
}void saveState() {FILE* file = fopen(SAVE_FILE, "w");if (!file) {printf("保存失败。\n");return;}fprintf(file, "%d\n", mainGarage->capacity);Node* current = mainGarage->front;while (current) {fprintf(file, "%s %ld %d %d\n", current->vehicle.plate, current->vehicle.arriveTime,current->vehicle.fuelLevel, current->vehicle.damageLevel);current = current->next;}fclose(file);printf("系统状态已保存。\n");
}void searchVehicle(char* plate) {Node* current = mainGarage->front;int position = 0;while (current != NULL) {position++;if (strcmp(current->vehicle.plate, plate) == 0) {// Find the actual parking spot using occupied arrayint parkingSpot = 0;for (int i = 0; i < mainGarage->capacity; ++i) {if (mainGarage->occupied[i]) {parkingSpot++;if (parkingSpot == position) {printf("找到装甲车 %s,位置 %d,油量 %d%%,损坏程度 %d%%\n", plate, i + 1, current->vehicle.fuelLevel, current->vehicle.damageLevel);return;}}}return; //Should not reach here, but added for safety}current = current->next;}printf("未找到装甲车牌号为 %s 的装甲车。\n", plate);
}void displayMenu() {printf("\n=== 装甲车库车辆动态监控辅助记录系统 ===\n");printf("1. 装甲车辆入场\n");printf("2. 装甲车辆出场\n");printf("3. 显示装甲车库状态\n");printf("4. 按照装甲车牌号查询车辆\n");printf("5. 查询装甲车辆油量并按油量排序\n");printf("6. 查询装甲车辆装备损坏情况并按损坏程度排序\n");printf("7. 保存并退出系统\n");printf("请选择操作 (1-7): ");
}int main() {int choice;char plate[MAX_PLATE_LEN];int fuelLevel, damageLevel, garageCapacity;mainGarage = createGarage(0);tempGarage = createGarage(100);loadState();if (mainGarage->capacity == 0) {printf("请输入主装甲车库容量:");scanf("%d", &garageCapacity);mainGarage->capacity = garageCapacity;}while (1) {displayMenu();scanf("%d", &choice);switch (choice) {case 1:printf("请输入车牌号:");scanf("%s", plate);printf("请输入油量百分比:");scanf("%d", &fuelLevel);printf("请输入损坏程度百分比:");scanf("%d", &damageLevel);enterGarage(plate, fuelLevel, damageLevel);break;case 2:printf("请输入车牌号:");scanf("%s", plate);leaveGarage(plate);break;case 3:displayStatus();break;case 4:printf("请输入要查找的车牌号:");scanf("%s", plate);searchVehicle(plate);break;case 5:displayFuelLevels();break;case 6:displayDamageLevels();break;case 7:saveState();printf("系统已保存,感谢使用!\n");free(mainGarage);free(tempGarage);return 0;default:printf("无效选择,请重试\n");}}return 0;
}

嗨,我是LucianaiB。如果你觉得我的分享有价值,不妨通过以下方式表达你的支持:👍 点赞来表达你的喜爱,📁 关注以获取我的最新消息,💬 评论与我交流你的见解。我会继续努力,为你带来更多精彩和实用的内容。

点击这里👉LucianaiB ,获取最新动态,⚡️ 让信息传递更加迅速。

相关文章:

C语言之装甲车库车辆动态监控辅助记录系统

&#x1f31f; 嗨&#xff0c;我是LucianaiB&#xff01; &#x1f30d; 总有人间一两风&#xff0c;填我十万八千梦。 &#x1f680; 路漫漫其修远兮&#xff0c;吾将上下而求索。 C语言之装甲车库车辆动态监控辅助记录系统 目录 一、前言 1.1 &#xff08;一&#xff09;…...

先进制造aps专题二十七 西门子opcenter aps架构分析

欧美的商业aps&#xff0c;主要就是sap apo,西门子opcenter aps,达索quintiq 从技术的层面&#xff0c;西门子aps是不如sap apo的&#xff0c;但是西门子aps是西门子数字化工厂产品的核心&#xff0c;有很多特色&#xff0c;所以分析 西门子aps主要分计划器和排产器两个部分 计…...

C++/QT环境下图像在窗口下等比例渲染绘制

本文中通过QT获取到opengl上下文环境,通过opengl3.0API将图像等比例渲染到QOpenGLWidget组件上面,相比cpu,渲染能力更强。 有以下四步骤。opengl基本知识点可参照之前文章OPENGL初学习 定义opengl渲染表面属性通过initializeGL接口初始化opengl上下文环境,然后加载并链接着…...

npm ERR! code CERT_HAS_EXPIRED

很不幸看到这个提示。 查了很多网上的解决方案&#xff0c;都提到一个解决方案&#xff1a; npm install -g npmlatest 靠就是执行install报的错&#xff0c;你要我通过install来解决这个问题。可见大多数人都是转发&#xff0c;从不自己试试。 第二个是看系统时间。这个基…...

[系统安全] 六十一.恶意软件分析 (12)LLM赋能Lark工具提取XLM代码的抽象语法树(初探)

您可能之前看到过我写的类似文章,为什么还要重复撰写呢?只是想更好地帮助初学者了解病毒逆向分析和系统安全,更加成体系且不破坏之前的系列。因此,我重新开设了这个专栏,准备系统整理和深入学习系统安全、逆向分析和恶意代码检测,“系统安全”系列文章会更加聚焦,更加系…...

网络Web存储之LocalStorage

文章目录 LocalStorage介绍定义特点兼容性常用方法存值取值删除指定键值对清空所有键值对通过索引获取键名获取所有值判断是否含有某个键&#xff08;key&#xff09;拓展遍历得到key存储和读取复杂类型的数据 应用场景 LocalStorage介绍 定义 LocalStorage 是HTML5提供的一种…...

HTML知识点复习

1.src 和 href 的区别 src&#xff1a;表示对资源的引用&#xff0c; src指向的内容会嵌入到其标签里。 当浏览器解析到该元素时候&#xff0c;会暂停其他资源的下载和处理&#xff0c; 直到将该资源加载、编译、执行完毕&#xff0c;所以js脚本一般会放在页面底部 href&…...

【Leetcode 热题 100】45. 跳跃游戏 II

问题背景 给定一个长度为 n n n 的 0 0 0 索引 整数数组 n u m s nums nums。初始位置为 n u m s [ 0 ] nums[0] nums[0]。 每个元素 n u m s [ i ] nums[i] nums[i] 表示从索引 i i i 向前跳转的最大长度。换句话说&#xff0c;如果你在 n u m s [ i ] nums[i] nums[i…...

《offer 来了:Java 面试核心知识点精讲 -- 原理篇》

在 Java 面试的战场上,只知皮毛可不行,面试官们越来越看重对原理的理解。今天就给大家分享一本能让你在面试中脱颖而出的 “武林秘籍”——《offer 来了:Java 面试核心知识点精讲 -- 原理篇》。 本书详细介绍了Java架构师在BAT和移动互联网公司面试中常被问及的核心知识,内…...

Spring Boot中的自动配置原理是什么

Spring Boot 自动配置原理 Spring Boot 的自动配置机制基于 条件化配置&#xff0c;通过 EnableAutoConfiguration 注解来启用。自动配置的核心原理是 基于类路径和环境条件来推断所需要的配置&#xff0c;Spring Boot 会根据项目中引入的依赖和当前环境来自动装配相关的配置项…...

蓝桥杯3525 公因数匹配 | 枚举+数学

题目传送门 这个题目是一个数学题&#xff0c;由于只需要找到存在大于1的公因数的两数&#xff0c;所以比较方便的做法是统计每一个数的&#xff08;质&#xff09;因数。可以通过筛法统计质因数降低复杂度&#xff0c;但是直接枚举因数也可以满足要求。使用字典记录每个因数出…...

elasticsearch基础

分布式搜索引擎01 1. 初始elasticsearch 1.1. 了解ES 1.1.1. elasticsearch的作用 elasticsearch是一款非常强大的开源搜索引擎&#xff0c;具备非常多强大功能&#xff0c;可以帮助我们从海量数据中快速找到需要的内容 例如&#xff1a; 在github搜索代码&#xff1a; 在电…...

【JsonViewer】Json格式化

使用 Notepad 对 Json 数据进行格式化处理&#xff0c;使数据在结构上更清晰 1.在线安装 安装之后&#xff0c;重启应用&#xff0c;在插件菜单栏即可看到 JsonViewer 选项&#xff0c;在 Notepad 中放入 Json 数据&#xff0c;点击 Format Json 进行数据格式化 2.离线安装 …...

线性代数概述

矩阵与线性代数的关系 矩阵是线性代数的研究对象之一&#xff1a; 矩阵&#xff08;Matrix&#xff09;是一个按照长方阵列排列的复数或实数集合&#xff0c;是线性代数中的核心概念之一。矩阵的定义和性质构成了线性代数中矩阵理论的基础&#xff0c;而矩阵运算则简洁地表示和…...

计算机毕业设计Python+卷积神经网络租房推荐系统 租房大屏可视化 租房爬虫 hadoop spark 58同城租房爬虫 房源推荐系统

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…...

Linux(DISK:raid5、LVM逻辑卷)

赛题拓扑: 题目: DISK 添加4块大小均为10G的虚拟磁盘,配置raid-5磁盘。创建LVM命名为/dev/vg01/lv01,大小为20G,格式化为ext4,挂在到本地目录/webdata,在分区内建立测试空文件disk.txt。[root@storagesrv ~]# yum install mdadm -y [root@storagesrv ~]# mdadm -C -n …...

RIME-CNN-LSTM-Attention多变量多步时序预测Matlab实现

SCI一区级 | Matlab实现RIME-CNN-LSTM-Multihead-Attention多变量多步时序预测 目录 SCI一区级 | Matlab实现RIME-CNN-LSTM-Multihead-Attention多变量多步时序预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 1.Matlab实现RIME-CNN-LSTM-Multihead-Attention霜冰算法…...

机器学习中的方差与偏差

文章目录 方差与偏差1.1 数据1.1.1 数据的分布1.1.2 拟合 1.2 方差与偏差1.2.1 泛化误差的拆分1.2.2 理解方差偏差 1.3 方差-偏差trade-off1.3.1 方差-偏差trade-off1.3.2 方差与偏差诊断 1.4 降低策略1.4.1 噪声1.4.2 高偏差1.4.3 高方差 方差与偏差 1.1 数据 1.1.1 数据的分…...

Ubuntu 22.04虚拟机安装配置调整(语言输入法字体共享剪切板等等

2025.01.07安装配置Ubuntu 22.04 记一下 快捷键 截屏 在设置-键盘-快捷键查看 跟搜到的不一样…不过shiftprint感觉也够用 安装 用的是VMware 参考&#xff1a;VMware中安装配置Ubuntu&#xff08;2024最新版 超详细&#xff09; 调教&#xff08;&#xff1f; 语言 改了…...

[创业之路-255]:《华为数字化转型之道》-1-主要章节、核心内容、核心思想

目录 前言&#xff1a;数字化转型对于企业而言&#xff0c;是一种全方位的变革 一、主要章节 1、认知篇&#xff08;第1~2章&#xff09;- Why 2、方法篇&#xff08;第3~5章&#xff09;- How 3、实践篇&#xff08;第6~10章&#xff09;- 实践 4、平台篇&#xff08;第…...

Java 接口安全指南

Java 接口安全指南 概述 在现代 Web 应用中&#xff0c;接口&#xff08;API&#xff09;是前后端交互的核心。然而&#xff0c;接口的安全性常常被忽视&#xff0c;导致数据泄露、未授权访问等安全问题。本文将详细介绍 Java 中如何保障接口安全&#xff0c;涵盖以下内容&am…...

Redis学习笔记1【数据类型和常用命令】

Redis学习笔记 基础语法 1.数据类型 String: 最基本的类型&#xff0c;可以存储任何数据&#xff0c;例如文本或数字。示例值为 hello world。Hash: 用于存储键值对&#xff0c;适合存储对象或结构体。示例值为 {"name": "Jack", "age": 21}。…...

Oracle graph 图数据库体验-安装篇

服务端安装 环境准备 安装数据库 DOCKER 安装23AI FREE &#xff0c;参考&#xff1a; https://container-registry.oracle.com/ords/f?p113:4:111381387896144:::4:P4_REPOSITORY,AI_REPOSITORY,AI_REPOSITORY_NAME,P4_REPOSITORY_NAME,P4_EULA_ID,P4_BUSINESS_AREA_ID:1…...

Android 13 动态显示隐藏 HomeButton,RecentsButton

com.android.launcher3.taskbar.NavbarButtonsViewController.initButtons mEnabledValue状态<T> StatePropertyHolder(T target, IntPredicate enabledCondition,Property<T, Float> property, float enabledValue, float disabledValue) {mEnableCondition = ena…...

前端开发中的状态管理与网络请求封装

本文将对比 Vuex 和 Pinia 在状态管理中的使用&#xff0c;并介绍如何封装 Axios 进行网络请求。此外&#xff0c;我们还将讨论动态路由、404 页面跳转以及面包屑导航的实现。 话不多说&#xff0c;正文开始~~~ 一、状态管理&#xff1a;Vuex 与 Pinia 对比 1. Vuex Vuex 是…...

AI 大爆发时代,音视频未来路在何方?

AI 大模型突然大火了 回顾2024年&#xff0c;计算机领域最大的变革应该就是大模型进一步火爆了。回顾下大模型的发展历程&#xff1a; 萌芽期&#xff1a;&#xff08;1950-2005&#xff09; 1956年&#xff1a;计算机专家约翰麦卡锡首次提出“人工智能”概念&#xff0c;标志…...

30分钟内搭建一个全能轻量级springboot 3.4 + 脚手架 <5> 5分钟集成好caffeine并使用注解操作缓存

快速导航 <1> 5分钟快速创建一个springboot web项目 <2> 5分钟集成好最新版本的开源swagger ui&#xff0c;并使用ui操作调用接口 <3> 5分钟集成好druid并使用druid自带监控工具监控sql请求 <4> 5分钟集成好mybatisplus并使用mybatisplus generator自…...

STM32 FreeRTOS中断管理

目录 FreeRTOS的中断管理 1、STM32中断优先级管理 2、FreeRTOS任务优先级管理 3、寄存器和内存映射寄存器 4、BASEPRI寄存器 5、FreeRTOS与STM32中断管理结合使用 vPortRaiseBASEPRI vPortSetBASEPRI 6、FromISR后缀 7、在中断服务函数中调用FreeRTOS的API函数需注意 F…...

第10章:Python TDD优化货币类方法与引入工厂方法

写在前面 这本书是我们老板推荐过的&#xff0c;我在《价值心法》的推荐书单里也看到了它。用了一段时间 Cursor 软件后&#xff0c;我突然思考&#xff0c;对于测试开发工程师来说&#xff0c;什么才更有价值呢&#xff1f;如何让 AI 工具更好地辅助自己写代码&#xff0c;或许…...

嵌入式硬件篇---基本组合逻辑电路

文章目录 前言基本逻辑门电路1.与门&#xff08;AND Gate&#xff09;2.或门&#xff08;OR Gate&#xff09;3.非门&#xff08;NOT Gate&#xff09;4.与非门&#xff08;NAND Gate&#xff09;5.或非门&#xff08;NOR Gate&#xff09;6.异或门&#xff08;XOR Gate&#x…...

回归人文主义,探寻情感本质:从文艺复兴到AI时代,我的情感探索之旅

回归人文主义&#xff0c;探寻情感本质&#xff1a;从文艺复兴到AI时代&#xff0c;我们的情感探索之旅 多年来&#xff0c;我们的团队一直关注人工智能&#xff0c;尤其是AI在音乐领域的应用研究。随着技术的不断演进&#xff0c;我们也不断反思&#xff1a;在“算法、代码、…...

接上回--综合AIDemo测试

一&#xff0c;前言 上回外挂了知识库之后&#xff0c;我们需要使用知识库中的信息&#xff0c;让AI为我们实际处理业务上的需求。 这里我们让AI扮演公司的人事助手&#xff0c;帮我们处理员工请假的业务。 具体流程如下 感知用户需要请假提取用户请假信息获取用户数据库中…...

几何数据结构之四叉树与八叉树

几何数据结构之四叉树与八叉树 四叉树的定义四叉树深度的计算公式推导假设&#xff1a;计算过程&#xff1a;1. 划分空间&#xff1a;2. 节点容纳的最小距离&#xff1a;3. 解出深度&#xff1a;4. 考虑常数项&#xff1a; 总结&#xff1a; 八叉树 四叉树的定义 四叉树&#…...

postman请求参数化

postman界面介绍 一、使用环境变量(Environment Variables)进行参数化 1、在请求中使用环境变量 在请求的url、请求头(Headers)、请求体(Body)等部分都可以使用环境变量。 URL 部分示例 点击 Postman 界面右上角的 “眼睛” 图标(Environment Quick Look)打开环境管理…...

java实现word转html(支持docx及doc文件)

private final static String tempPath "C:\\Users\\xxx\\Desktop\\Word2Html\\src\\test\\";//图片及相关文件保存的路径public static void main(String argv[]) {try {JFileChooser fileChooser new JFileChooser();fileChooser.setDialogTitle("Select a …...

<电子幽灵>开发笔记:BAT基础笔记(一)

BAT脚本基础笔记(一) 介绍 费曼学习法最重要的部分&#xff0c;即把知识教给一个完全不懂的孩子——或者小白。 为了更好的自我学习&#xff0c;也为了让第一次接触某个知识范畴的同学快速入门&#xff0c;我会把我的学习笔记整理成电子幽灵系列。 提示&#xff1a;作为低代码…...

Leetcode::3427.变长子数组求和

给你一个长度为 n 的整数数组 nums 。对于 每个 下标 i&#xff08;0 < i < n&#xff09;&#xff0c;定义对应的子数组 nums[start ... i]&#xff08;start max(0, i - nums[i])&#xff09;。 返回为数组中每个下标定义的子数组中所有元素的总和。 子数组 是数组中…...

通过以太网加载linux内核、设备树、根文件系统方法(以stm32MP135为例)

0 硬件平台 正点原子stm32MP135开发板 1 通过以太网加载linux内核、设备树、根文件系统方法&#xff08;以stm32MP135为例&#xff09; 在产品正式发布前&#xff0c;为了调试方便&#xff0c;我们可以使用以太网加载linux内核、设备树、根文件系统以加快调试速度。本文以stm3…...

mac配置stable diffusion以及模型出图优化

1. 基础stable diffusion webui安装 使用的工程是stable-diffusion-webui&#xff0c;直接clone下来即可。 然后创建一个conda环境&#xff0c;python为3.9 激活conda环境后&#xff0c;执行./webui.sh即可。脚本会自动安装必要的包&#xff0c;然后启动网页。 默认有一个sd…...

LeetCode热题100(子串篇)

LeetCode热题100 说是子串&#xff0c;其实是子区间~ 560. 和为 K 的子数组 给你一个整数数组 nums 和一个整数 k &#xff0c;请你统计并返回 该数组中和为 k 的子数组的个数 。 子数组是数组中元素的连续非空序列。 思路 思路&#xff1a; 和为k的子数组&#xff0c;看到…...

从密码学原理与应用新方向到移动身份认证与实践

相关学习资料放下面啦&#xff01; 记得关注❤️&#xff5e;后续分享更多资料 通过百度网盘分享的文件&#xff1a;从密码学原理与应... 链接https://pan.baidu.com/s/1mHpHkvPuf8DUwReQkoYQlw?pwdGza7 提取码&#xff1a;Gza7 复制这段内容打开「百度网盘APP 即可获取」 记…...

【Flink系列】9. Flink容错机制

9. 容错机制 在Flink中&#xff0c;有一套完整的容错机制来保证故障后的恢复&#xff0c;其中最重要的就是检查点。 9.1 检查点&#xff08;Checkpoint&#xff09; 9.1.1 检查点的保存 1&#xff09;周期性的触发保存 “随时存档”确实恢复起来方便&#xff0c;可是需要我…...

【物联网】ARM核介绍

文章目录 一、芯片产业链1. CPU核(1)ARM(2)MIPS(3)PowerPc(4)Intel(5)RISC-V 2. SOC芯片(1)主流厂家(2)产品解决方案 3. 产品 二、ARM核发展1. 不同架构的特点分析(1)VFP(2)Jazelle(3)Thumb(4)TrustZone(5)SIMD(6)NEON 三、ARM核(ARMv7)工作模式1. 权限级别(privilege level)2.…...

spring的事物管理的认知

事物 它是一个原子操作要么全部不执行&#xff0c;要么全部执行成功&#xff0c;如果有一个失败也会撤销&#xff0c;它保证用户每一次的操作都是可靠的&#xff0c;即使时出现了错误也不至于破坏数据的完整性 它包含了四种特性&#xff1a; 原子性&#xff1a;保证事物要么…...

QT跨平台应用程序开发框架(3)—— 信号和槽

目录 一&#xff0c;基本概念 二&#xff0c;connect函数使用 2.1 connect 2.2 Qt内置信号和槽 2.3 一些细节 三&#xff0c;自定义信号和槽 3.1 自定义槽函数 3.2 自定义信号 3.3 带参数的信号槽 四&#xff0c;信号和槽的意义 五&#xff0c;信号和槽断开连接 六&…...

技术面试中的软素质技巧性答复集锦

1、请你自我介绍一下你自己&#xff1f; 回答提示&#xff1a;一般人回答这个问题过于平常&#xff0c;只说姓名、年龄、爱好、工作经验&#xff0c;这些在简历上都有。其实&#xff0c;企业最希望知道的是求职者能否胜任工作&#xff0c;包括&#xff1a;最强的技能、最深入研…...

JavaWeb项目——如何处理管理员登录和退出——笔记

一、知识点 1、WebServlet注解的使用 WebServlet注解是Servlet 3.0引入的一个特性&#xff0c;它允许开发者在Servlet类上使用注解来声明Servlet的一些属性&#xff0c;从而避免在web.xml文件中进行配置。这种方式简化了Servlet的配置过程&#xff0c;使得代码更加简洁&#…...

函数递归的介绍

1.递归的定义 在C语言中&#xff0c;递归就是函数自己调用自己 上面的代码就是 main 函数在函数主体内 自己调用自己 但是&#xff0c;上面的代码存在问题&#xff1a;main 函数反复地 自己调用自己 &#xff0c;不受限制&#xff0c;停不下来。 最终形成死递归&#xff0c;…...

昇腾环境ppstreuct部署问题记录

测试代码 我是在华为昇腾910B3上测试的PPStructure。 import os import cv2 from PIL import Image #from paddleocr import PPStructure,draw_structure_result,save_structure_res from paddleocr_asyncio import PPStructuretable_engine PPStructure(show_logTrue, imag…...

《知识图谱:鸿蒙NEXT中人工智能的智慧基石》

在鸿蒙NEXT系统的人工智能应用中&#xff0c;知识图谱技术犹如一座智慧基石&#xff0c;为系统的智能化提供了强大的知识支撑&#xff0c;开启了更智能、更高效、更个性化的交互新时代。 提升语义理解能力 知识图谱以其结构化的知识表示方式&#xff0c;将各种实体和它们之间…...