数据结构第三章作业

This commit is contained in:
2023-10-29 11:17:01 +08:00
parent 0069fae271
commit afb7c5086e
11 changed files with 842 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
// @Time : 2023-10-26 16:40:50
// @FileName: test_controller.cpp
// @Author : 423A35C7
// @Software: VSCode
#include "../src/MVC.cpp"
// #ifdef __WIN32__
// 添加"-D_HAS_STD_BYTE=0",的方法不知道为什么没用
// #include <windows.h>
// #else
// #include <unistd.h>
// #define Sleep(a) usleep(a * 1000) // 需要小于一秒
// #endif
// 以下的是通过向类传递参数设置的
int probability_num = DEFAULT_PROBABILITY_NUM; // 每个时刻有1/probability_num的概率来人
int speed = DEFAULT_SPEED; // 每个窗口办理的速度
int_ total_time = 1e2; // 总时刻数
int max_money = MAX_MONEY; // 最大携带金额
int window_num = DEFAULT_WINDOW_NUM; // 柜台数量
double walk_speed = DEFAULT_WALK_SPEED; // 人的走路速度
// 以下的是通过全局变量设置的
int sleep_time = DEFAULT_SLEEP_TIME; // 每次刷新间隔多少毫秒
int base_x = DEFAULT_BASE_X; // 起始位置距离终端上边几个字符的距离
int base_y = DEFAULT_BASE_Y; // 起始位置距离终端左边几个字符的距离
int sep = DEFAULT_SEP; // 每个窗口间隔多少距离
int gate_x = DEFAULT_GATE_X; // 大门的位置终端上边几个字符的距离
int gate_y = DEFAULT_GATE_Y; // 大门的位置终端左边几个字符的距离
int main() {
Status temp = main_simple();
if (temp != OK) return temp;
temp = main_multi();
return temp;
}

View File

@@ -0,0 +1,15 @@
#include "model.hpp"
int main() {
SingleQueueModel<Customer> simple_queue;
Customer person = {1, 2};
Customer person2 = {3243, 999};
simple_queue.push(person);
simple_queue.push(person2);
std::cout << simple_queue.shift() << std::endl;
simple_queue.push(person2);
std::cout << simple_queue.shift() << std::endl;
std::cout << simple_queue.shift() << std::endl;
printf("\033[2J\033[10;37Hhello world\033[5m");
return 0;
}

View File

@@ -0,0 +1,31 @@
// @Time : 2023-10-24 19:10:31
// @FileName: test_view.cpp
// @Author : 423A35C7
// @Software: VSCode
#include <bits/stdc++.h>
#include "view.hpp"
using namespace std;
template <typename T>
class TestModel : public vector<T> {
public:
using vector<T>::vector; // 这样好像可以继承构造函数
int_ get_length() {
return this->size();
}
};
int main() {
TestModel<int> a {1, 2, 3, 4, 5};
auto background_view = BackgroundView(DEFAULT_GATE_X, DEFAULT_GATE_Y);
auto queue_view = SimpleQueueView<int, TestModel<int>>(a, 10, 10);
// queue_view.init();
queue_view.refresh();
TestModel<int> b {10, 20, 30, 40, 50};
auto queue_view2 = SimpleQueueView<int, TestModel<int>>(b, 20, 50);
// queue_view2.init();
queue_view2.refresh();
return 0;
}