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

【上海大学《面向对象程序设计A》课程小项目报告】抽象向量类模板及其派生类

1 项目内容及要求

本项目通过设计一个抽象向量类模板,以及一个通用的向量类模板和一个字符串类作为其派生类,以满足各种应用场景中的数据存储和处理需求。

项目内容:

  1. 抽象向量类模板。
  2. 派生向量类。
  3. 派生字符串类。
  4. 测试及异常处理。
  5. 联合测试

2.1 抽象向量类模板

2.1.1 数据成员设计

int  num;//向量的维度
T* p;//存储元素的数组 

2.1.2 成员函数设计

VECTOR(int size = 0, const T* x = NULL)//构造函数
VECTOR(const VECTOR& v)//拷贝构造函数
virtual ~VECTOR()//虚析构函数
VECTOR& operator=(const VECTOR& v)//赋值运算符重载
T& operator[](int index)//用于访问特定位置的元素
void resize(int size)//重设容器大小
virtual void Output(ostream& out) const = 0;//纯虚函数
virtual void Input(istream& in) = 0;//纯虚函数

2.2 派生向量类模板

2.2.1 定义纯虚函数

void Output(ostream& out) const
{if (__super::num == 0) out << "( )";else{out << "(" << __super::p[0];for (int i = 1; i < __super::num; i++){out << "," << __super::p[i];}out << ")" << endl;}
}void Input(istream& in)
{char c;T x;__super::resize(0);in >> c;if (c != '(') return;while (in >> x){__super::resize(__super::num + 1);__super::p[__super::num - 1] = x;in >> c;if (c == ')') break;}
}

2.2.2 成员函数设计

Vector(int size = 0, const T* x = NULL)//构造函数 
Vector operator+(const Vector& v)//+运算符重载 

2.2.3 测试及异常处理

int TestVector()
{int a[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };double x[8];for (int i = 0; i < 8; i++)x[i] = sqrt(double(i));Vector<int> vi1(10, a), vi2(5, a + 5);Vector<double> vd1(8, x), vd2(3, x);cout << "原始数据:" << endl;cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "调整维数到5:" << endl;vi1.resize(5);vi2.resize(5);vd1.resize(5);vd2.resize(5);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n将数据写入文件 vector.txt 中..." << endl;ofstream outfile("vector.txt");outfile << vi1 << '\n'<< vi2						<< vd1 << '\n' << vd2 << endl;outfile.close();cout << "\n清除对象的数据(即调整维数到0)..." << endl;vi1.resize(0);vi2.resize(0);vd1.resize(0);vd2.resize(0);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n从文件 vector.txt 中读取的数据:" << endl;ifstream infile("vector.txt");infile >> vi1 >> vi2 >> vd1 >> vd2;infile.close();cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\nvi1 + vi2 = " << vi1 + vi2<< "\nvd1 + vd2 = " << vd1 + vd2 << endl;cout << "\n异常处理测试" << endl;Vector<int> v;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;//如果格式错误,则抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}

运行结果:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

2.3 派生字符串类

2.3.1 定义纯虚函数

void Output(ostream& out) const
{for (int i = 0; i < __super::num; i++){out << p[i];}
}void Input(istream& in)
{string temp;in >> temp;*this = temp.c_str();
}

2.3.2 成员函数设计

String(const char* x = "")//构造函数  
String operator+(const String& s)//+运算符重载 

2.3.3 测试及异常处理

int TestString()
{String str1 = "Hello", str2 = str1, str3;// 转换构造		拷贝构造 	默认构造cout << "原始数据(双引号是另外添加的):" << endl;cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;str3 = str2;				// 赋值运算str1 = "C++ program.";str2 = str3 + ", world!";	// 拼接运算cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n将数据写入文件 string.txt 中..." << endl;ofstream outfile("string.txt");outfile << str1 << '\n'<< str2 << '\n'<< str3 << endl;outfile.close();cout << "\n清除对象的数据(即调整长度到0)..." << endl;str1.resize(0);str2.resize(0);str3.resize(0);cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n从文件 string.txt 中读取的数据:" << endl;ifstream infile("string.txt");infile >> str1>> str2>> str3;infile.close();cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n异常处理测试" << endl;String str4 = "Hello";try{cout << str4 << endl;cout << str4[10] << endl;//越界访问,抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}

运行结果:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

3 联合测试

#include "Vec.h"int TestVector(), TestString(), Test();void menu()
{cout << "\n1 --- testing Vector          [v]"<< "\n2 --- testing String          [s]"<< "\n3 --- testing Vector & String [m]"<< "\n0 --- exit                    [q]"<< endl;
}int main()
{char choice = '0';do{menu();cin >> choice;switch (choice){case '1':case 'v':case 'V':	TestVector();	break;case '2':case 's':case 'S':	TestString();	break;case '3':case 'm':case 'M':	Test();			break;case '0':case 'q':case 'Q':case 27:	choice = 0;		break;default:	cout << "选择错误,重新选择" << endl;	break;}} while (choice);return 0;
}int Test()
{Vector<int> v;String str;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;}catch (const char* str) { cout << str << endl;return 0;}cout << v << endl;cin.sync();			// 刷新输入流缓冲区(目的是读取并丢弃向量后的换行符)cout << "请输入一个字符串。如 abc 12345   xyz" << endl;cin >> str;cout << str << endl;cout << "\n将数据写入文件 output.txt 中..." << endl;ofstream outfile("output.txt");outfile << v << endl<< str << endl;outfile.close();cout << "\n清除对象的数据..." << endl;v.resize(0);str.resize(0);cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;cout << "\n从文件 output.txt 中读取的数据:" << endl;ifstream infile("output.txt");infile >> v;infile >> str;infile.close();cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;return 0;
}

运行结果:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

4 完整代码

4.1 Vec.h

#pragma once
#define _CRT_SECURE_NO_WARNINGS	1
#include <iostream>
#include <fstream>
#include <string>
using namespace std;template <typename T> class VECTOR
{
public:VECTOR(int size = 0, const T* x = NULL){num = (size > 0) ? size : 0;p = NULL;if (num > 0){p = new T[num];for (int i = 0; i < num; i++)p[i] = (x == NULL) ? 0 : x[i];}}VECTOR(const VECTOR& v){num = v.num;p = NULL;if (num > 0){p = new T[num];for (int i = 0; i < num; i++)p[i] = v.p[i];}}virtual ~VECTOR(){if (p != NULL) delete[] p;}VECTOR& operator=(const VECTOR& v){if (num != v.num){if (p != NULL) delete[] p;p = new T[num = v.num];}for (int i = 0; i < num; i++)p[i] = v.p[i];return *this;}T& operator[](int index){if (index >= num) throw "越界访问";else return p[index];}void resize(int size){if (size < 0 || size == num) return;else if (size == 0){if (p != NULL) delete[] p;num = 0;p = NULL;}else{T* temp = p;p = new T[size];for (int i = 0; i < size; i++)p[i] = (i < num) ? temp[i] : 0;num = size;delete[] temp;}}virtual void Output(ostream& out) const = 0;virtual void Input(istream& in) = 0;int num;//向量的维度T* p;//存储元素的数组
};template <typename T> ostream& operator<<(ostream& out, const VECTOR<T>& v)
{v.Output(out);return out;
}template <typename T> istream& operator>>(istream& in, VECTOR<T>& v)
{v.Input(in);return in;
}template <typename T> class Vector :public VECTOR<T>
{
public:Vector(int size = 0, const T* x = NULL) :VECTOR<T>(size, x) {}void Output(ostream& out) const{if (__super::num == 0) out << "( )";else{out << "(" << __super::p[0];for (int i = 1; i < __super::num; i++){out << "," << __super::p[i];}out << ")" << endl;}}void Input(istream& in){char c;T x;__super::resize(0);in >> c;if (c != '(')	throw "格式错误";while (in >> x){__super::resize(__super::num + 1);__super::p[__super::num - 1] = x;in >> c;if (c == ')') break;}}Vector operator+(const Vector& v){Vector Add;if (__super::num == v.__super::num){Add.resize(__super::num);for (int i = 0; i < __super::num; i++){Add[i] = __super::p[i] + v.__super::p[i];}}return Add;}};class String : public VECTOR<char>
{
public:String(const char* x = "") : VECTOR<char>(strlen(x), x) { }void Output(ostream& out) const{for (int i = 0; i < __super::num; i++){out << p[i];}}void Input(istream& in){string temp;in >> temp;*this = temp.c_str();}String operator+(const String& s){int i, j;String add;add.__super::num = __super::num + s.__super::num;add.p = new char[add.__super::num];for (i = 0; i < __super::num; i++){add.p[i] = p[i];}for (j = 0; j < s.__super::num; j++){add.p[i + j] = s.p[j];}return add;}};

4.2 Test.cpp

#include "Vec.h"int TestVector(), TestString(), Test();void menu()
{cout << "\n1 --- testing Vector          [v]"<< "\n2 --- testing String          [s]"<< "\n3 --- testing Vector & String [m]"<< "\n0 --- exit                    [q]"<< endl;
}int main()
{char choice = '0';do{menu();cin >> choice;switch (choice){case '1':case 'v':case 'V':	TestVector();	break;case '2':case 's':case 'S':	TestString();	break;case '3':case 'm':case 'M':	Test();			break;case '0':case 'q':case 'Q':case 27:	choice = 0;		break;default:	cout << "选择错误,重新选择" << endl;	break;}} while (choice);return 0;
}int Test()
{Vector<int> v;String str;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;}catch (const char* str) { cout << str << endl;return 0;}cout << v << endl;cin.sync();			// 刷新输入流缓冲区(目的是读取并丢弃向量后的换行符)cout << "请输入一个字符串。如 abc 12345   xyz" << endl;cin >> str;cout << str << endl;cout << "\n将数据写入文件 output.txt 中..." << endl;ofstream outfile("output.txt");outfile << v << endl<< str << endl;outfile.close();cout << "\n清除对象的数据..." << endl;v.resize(0);str.resize(0);cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;cout << "\n从文件 output.txt 中读取的数据:" << endl;ifstream infile("output.txt");infile >> v;infile >> str;infile.close();cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;return 0;
}

4.3 TestString.cpp

#include "Vec.h"int TestString()
{String str1 = "Hello", str2 = str1, str3;// 转换构造		拷贝构造 	默认构造cout << "原始数据(双引号是另外添加的):" << endl;cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;str3 = str2;				// 赋值运算str1 = "C++ program.";str2 = str3 + ", world!";	// 拼接运算cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n将数据写入文件 string.txt 中..." << endl;ofstream outfile("string.txt");outfile << str1 << '\n'<< str2 << '\n'<< str3 << endl;outfile.close();cout << "\n清除对象的数据(即调整长度到0)..." << endl;str1.resize(0);str2.resize(0);str3.resize(0);cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n从文件 string.txt 中读取的数据:" << endl;ifstream infile("string.txt");infile >> str1>> str2>> str3;infile.close();cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n异常处理测试" << endl;String str4 = "Hello";try{cout << str4 << endl;cout << str4[10] << endl;//越界访问,抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}

4.4 TestVector.cpp

#include "Vec.h"int TestVector()
{int a[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };double x[8];for (int i = 0; i < 8; i++)x[i] = sqrt(double(i));Vector<int> vi1(10, a), vi2(5, a + 5);Vector<double> vd1(8, x), vd2(3, x);cout << "原始数据:" << endl;cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "调整维数到5:" << endl;vi1.resize(5);vi2.resize(5);vd1.resize(5);vd2.resize(5);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n将数据写入文件 vector.txt 中..." << endl;ofstream outfile("vector.txt");outfile << vi1 << '\n'<< vi2						<< vd1 << '\n' << vd2 << endl;outfile.close();cout << "\n清除对象的数据(即调整维数到0)..." << endl;vi1.resize(0);vi2.resize(0);vd1.resize(0);vd2.resize(0);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n从文件 vector.txt 中读取的数据:" << endl;ifstream infile("vector.txt");infile >> vi1 >> vi2 >> vd1 >> vd2;infile.close();cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\nvi1 + vi2 = " << vi1 + vi2<< "\nvd1 + vd2 = " << vd1 + vd2 << endl;cout << "\n异常处理测试" << endl;Vector<int> v;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;//如果格式错误,则抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}

注意

包含项目的文件夹中以下三个文本文档需要自行创建:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

相关文章:

【上海大学《面向对象程序设计A》课程小项目报告】抽象向量类模板及其派生类

1 项目内容及要求 本项目通过设计一个抽象向量类模板&#xff0c;以及一个通用的向量类模板和一个字符串类作为其派生类&#xff0c;以满足各种应用场景中的数据存储和处理需求。 项目内容&#xff1a; 抽象向量类模板。派生向量类。派生字符串类。测试及异常处理。联合测试…...

Leetcode每日一题学习训练——Python3版(到达首都的最少油耗)

版本说明 当前版本号[20231205]。 版本修改说明20231205初版 目录 文章目录 版本说明目录到达首都的最少油耗理解题目代码思路参考代码 原题可以点击此 2477. 到达首都的最少油耗 前去练习。 到达首都的最少油耗 ​ 给你一棵 n 个节点的树&#xff08;一个无向、连通、无环…...

Java面试题(每天10题)-------连载(42)

目录 Spring篇 1、Spring Bean的作用域之间有什么区别&#xff1f; 2、什么是Spring inner beans&#xff1f; 3、Spring框架中的单例Beans是线程安全的吗&#xff1f; 4、请举例说明如何在Spring中诸如一个Java Collection&#xff1f; 5、如何向Spring Bean中诸如一个J…...

netty websocket学习

【硬核】肝了一月的Netty知识点 超详细Netty入门&#xff0c;看这篇就够了&#xff01; bzm_netty_sb netty-chat vuewebsokect实现实时聊天&#xff0c;可单聊、可群聊&#xff08;一&#xff09; vue实现聊天栏定位到最底部&#xff08;超简单、可直接复制使用&#xff09;…...

【数据结构】环形队列

环形队列 1. 定义 环形队列就是将队列在逻辑上看作环形结构、物理上仍是数组形式存储的一种数据结构。 其实现主要分为两种情况&#xff1a; 浪费空间法记录空间法 2. 实现 实现要考虑的是成员变量 2.1 记录空间法 使用used标识当前存储了多少元素&#xff0c;如果为空&a…...

嵌入式C编码规范

嵌入式C编码规范 编码规范&#xff0c;没有最好&#xff0c;只有最合适&#xff0c;有但不执行不如没有。 嵌入式C编码规范 https://mp.weixin.qq.com/s/z4u3YnF6vdQ1olsLeF-y_A 更多嵌入式信息请关注微信公众号【嵌入式系统】...

Golang 并发 — 流水线

并发模式 我们可以将流水线理解为一组由通道连接并由 goroutine 处理的阶段。每个阶段都被定义为执行特定的任务&#xff0c;并按顺序执行&#xff0c;下一个阶段在前一个阶段完成后开始执行。 流水线的另一个重要特性是&#xff0c;除了连接在一起&#xff0c;每个阶段都使用…...

Elasticsearch:什么是非结构化数据?

非结构化数据定义 非结构化数据是指未按照设计的模型或结构组织的数据。 非结构化数据通常被归类为定性数据&#xff0c;可以是人类或机器生成的。 非结构化数据是最丰富的可用数据类型&#xff0c;经过分析后&#xff0c;可用于指导业务决策并在许多其他用例中实现业务目标。…...

15:00的面试,15:06就出来了,问的问题过于变态了。。。

从小厂出来&#xff0c;没想到在另一家公司又寄了。 到这家公司开始上班&#xff0c;加班是每天必不可少的&#xff0c;看在钱给的比较多的份上&#xff0c;就不太计较了。没想到5月一纸通知&#xff0c;所有人不准加班&#xff0c;加班费不仅没有了&#xff0c;薪资还要降40%…...

Web自动化测试怎么做?Web网页测试全流程解析

1、功能测试 web网页测试中的功能测试&#xff0c;主要测试网页中的所有链接、数据库连接、用于在网页中提交或获取用户信息的表单、Cookie 测试等。 &#xff08;1&#xff09;查看所有链接&#xff1a; 测试从所有页面到被测特定域的传出链接。 测试所有内部链接。 测…...

MySQL数据库SQLSTATE[22007]: Invalid datetime format 日期类型不能为空值的解决办法

如果你的数据库是mysql&#xff0c; 如果你创建表或插入数据时遇到的BUG–它长这样&#xff1a; Invalid datetime format: 1292 Incorrect datetime value: ‘’ for column ‘xxx’ at row 1 或 1067 - Invalid default value for ‘xx’ 那么我将赐予你 两套剑法: &#…...

搬运工让你分分钟了解Web接口测试

01、什么是接口 百度说&#xff1a;接口泛指实体把自己提供给外界的一种抽象化物&#xff08;可以为另一实体&#xff09;&#xff0c;用以由内部操作分离出外部沟通方法&#xff0c;使其能被内部修改而不影响外界其他实体与其交互的方式 上面这句有点抽象&#xff0c;网上的…...

作业12.5

1.定义一个基类 Animal&#xff0c;其中有一个虛函数perform&#xff08;)&#xff0c;用于在子类中实现不同的表演行为。 #include <iostream>using namespace std; class Animal { private:int weight; public:Animal(){}Animal(int weight):weight(weight){}virtual …...

leetCode 47. 全排列 II + 回溯算法 + 图解 + 笔记

给定一个可包含重复数字的序列 nums &#xff0c;按任意顺序 返回所有不重复的全排列 示例 1&#xff1a; 输入&#xff1a;nums [1,1,2] 输出&#xff1a; [[1,1,2],[1,2,1],[2,1,1]] 示例 2&#xff1a; 输入&#xff1a;nums [1,2,3] 输出&#xff1a;[[1,2,3],[1,3,2…...

Maya 2024(3D建模、动画和渲染软件)

Maya 2024是一款非常强大的3D建模、动画和渲染软件&#xff0c;它提供了许多新功能和改进&#xff0c;以帮助建模师、动画师和渲染师更加高效地进行创作。 在建模方面&#xff0c;Maya 2024引入了Symmetry&#xff08;对称&#xff09;功能&#xff0c;可以在网格两侧生成均匀…...

C++作业5

完成沙发床的多继承&#xff08;有指针成员&#xff09; 代码&#xff1a; #include <iostream>using namespace std;class Bed { private:double *money; public:Bed(){cout << "Bed::无参构造函数" << endl;}Bed(double money):money(new doub…...

Go语言很难吗?为什么 Go 岗位这么少?

其实这个话题已经躺在我的 TODO 里很久了&#xff0c;近来很多社区的小伙伴都私下来交流&#xff0c;也有在朋友圈看吐槽 Go 上海的大会没什么人。还不如 Rust 大会&#xff0c;比较尴尬。 今天主要是从个人角度看看为什么 Go 岗位看起来近来很难的样子&#xff1f; 盘一下数…...

为什么要替换 Object.defineProperty?

目录 前言&#xff1a;为什么要替换 Object.defineProperty&#xff1f; 详解&#xff1a;为什么要替换 Object.defineProperty&#xff1f; 总结&#xff1a; 前言&#xff1a;为什么要替换 Object.defineProperty&#xff1f; JavaScript中的Object.defineProperty是一种…...

百马百担c语言编程

以下是一个百马百担问题的C语言编程实现&#xff1a; #include <stdio.h>int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); int a[n], b[m], c[k]; for (int i 0; i < n; i) { scanf("%d", &a[i]);…...

C++检测字符串中有效的括号个数

匹配一个字符串buf中&#xff0c;连续包换运算符reg的次数&#xff1a; #include <iostream>//return 返回匹配的字符个数 //buf, 要检测的字符串 //reg, 包含的连续运算符 int GetMatchCount(std::string& buf, std::string& reg) {int nMatchCount 0;if (reg.…...

Spring Boot项目接入Claude的3种生产级方案,含安全沙箱、审计日志与LLM调用熔断机制

更多请点击&#xff1a; https://intelliparadigm.com 第一章&#xff1a;Spring Boot项目接入Claude的3种生产级方案&#xff0c;含安全沙箱、审计日志与LLM调用熔断机制 在高可用AI服务场景中&#xff0c;将Claude大模型能力安全、可控、可观测地集成进Spring Boot应用&…...

Narrative-craft:工程化叙事框架的设计、实现与集成指南

1. 项目概述与核心价值最近在GitHub上看到一个挺有意思的项目&#xff0c;叫“Narrative-craft”&#xff0c;作者是chengjialu8888。光看名字&#xff0c;你可能会觉得这又是一个讲“叙事”或者“故事创作”的抽象工具。但点进去仔细研究后&#xff0c;我发现它远不止于此。这…...

千问 LeetCode 2281.巫师的总力量和 public int totalStrength(int[] strength)

LeetCode 2281. 巫师的总力量和 是一道经典的 贡献法 + 单调栈 + 前缀和的前缀和 题目。题目要求对数组的所有非空连续子数组,计算: min(subarray) * sum(subarray) 的总和,并对 10^9 + 7 取模。 ✅ 解题思路(核心思想) 我们 不枚举所有子数组(那样是 O(n)),而是 枚…...

别再死记硬背段码了!用Python脚本自动生成数码管显示码表(支持共阳/共阴)

用Python解放双手&#xff1a;动态生成数码管段码的工程实践 数码管作为电子设计中最基础的显示元件之一&#xff0c;其驱动原理看似简单却暗藏玄机。传统开发流程中&#xff0c;工程师需要反复查阅手册或记忆十六进制段码&#xff0c;这种低效模式在复杂项目中将消耗大量时间。…...

API集成管理之核心产品核心能力与数据盘点

API集成管理是企业数字化转型中的核心基础设施&#xff0c;它解决的是系统之间如何高效、安全、可控地进行数据交换与业务协同的问题。一套完善的API集成管理方案&#xff0c;能够帮助企业打通数据孤岛、实现能力复用、构建开放生态。本文基于公开资料&#xff0c;对五款代表性…...

多层板钻靶精度为什么越来越难控制?一套X-RAY预对位+六轴机械手的自动化方案解析

背景在高多层板和HDI板生产中&#xff0c;钻靶精度是影响良率的核心环节之一。压合后内层靶点被外层铜箔覆盖&#xff0c;传统视觉系统只能识别表面标记&#xff0c;无法获取真实的内层位置数据。同时&#xff0c;上料对位若依赖人工操作&#xff0c;放板角度和位置存在批次差异…...

OpenClaw-Skills:模块化自动化技能库的设计、开发与编排实战

1. 项目概述与核心价值最近在GitHub上看到一个挺有意思的项目&#xff0c;叫blessonism/openclaw-skills。光看名字&#xff0c;你可能会有点摸不着头脑&#xff0c;这“OpenClaw”和“Skills”组合在一起&#xff0c;到底想干什么&#xff1f;作为一个在开源社区和自动化工具领…...

Docker 部署 XiuXianGame 文字修仙游戏:极空间 NAS 上随时挂机刷资源

前言 挂机刷资源&#xff0c;躺平修成仙。 这类文字修仙游戏&#xff0c;说白了就是佛系养成为主&#xff0c;不用时刻盯着&#xff0c;挂着就行。但问题是——大多数要么得在本地电脑跑&#xff0c;要么依赖第三方平台&#xff0c;体验受限。把这套东西跑在自己的 NAS 上&am…...

构建个人知识管理系统:基于技能树与间隔重复的学习框架

1. 项目概述&#xff1a;构建个人专属的“人类技能树” 最近在折腾一个挺有意思的项目&#xff0c;我把它叫做“人类技能树”。这名字听起来有点科幻&#xff0c;但内核其实很朴素&#xff1a;我们每个人从小到大&#xff0c;从学校到职场&#xff0c;都在不断地学习各种技能&a…...

Perplexity Pro年度订阅最后48小时决策清单:7个必测场景+1张动态成本计算器+2024新政策下仅剩的3种合规降本路径

更多请点击&#xff1a; https://intelliparadigm.com 第一章&#xff1a;Perplexity Pro订阅值不值得 核心能力对比&#xff1a;免费版 vs Pro版 Perplexity Pro 提供实时联网搜索、多文件上传解析&#xff08;PDF/DOCX/CSV&#xff09;、无限次深度追问及自定义AI工作区等…...