【上海大学《面向对象程序设计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;
}

注意

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

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/220874.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

顶级资源!五个免费图标素材网站

图片太花哨了&#xff0c;纯文本太单调了&#xff1f;别忘了设计师的魔法武器——图标&#xff01;图标材料是UI设计师不可缺少的一部分。优秀的图标设计不仅可以提高界面美感&#xff0c;还可以提高用户的互动体验&#xff0c;帮助用户更好地了解应用程序的功能和信息。在本文…

SpringBoot+SSM项目实战 苍穹外卖(3)

继续上一节的内容&#xff0c;本节完成菜品管理功能&#xff0c;包括公共字段自动填充、新增菜品、菜品分页查询、删除菜品、修改菜品。 目录 公共字段自动填充新增菜品文件上传实现新增菜品实现 useGeneratedKeys 菜品分页查询删除菜品修改菜品根据id查询菜品实现修改菜品实现…

【unity3D】Transform组件(如何访问和获取Transform组件)

&#x1f497; 未来的游戏开发程序媛&#xff0c;现在的努力学习菜鸡 &#x1f4a6;本专栏是我关于游戏开发的学习笔记 &#x1f236;本篇是unity的Transform组件 Transform组件 基础知识介绍三个成员变量常用属性扩展 Transform的相关查找方法静态方法 基础知识 介绍 在Unit…

在线网页视频提取工具哪个好用?建议收藏!

随着短视频的崛起&#xff0c;很多人都喜欢将视频下载到手机中慢慢观看&#xff0c;这样可以避免在线播放的卡顿问题&#xff0c;但是会遇到一个问题就是在线网页视频提取工具哪个好用&#xff0c;有的可以提取但是画质太差模糊&#xff0c;有的自带水印飞来飞去。今天小编给大…

【AXI死锁】

单主机单从机死锁 AXI4没有WID,所以比较严格,即写数据通道的数据必须严格的按照写地址通道的数据顺序传送,比如AW通道发送ADDR0,ADDR1,ADDR2三笔写操作,每个写操作burst length=2,那么W通道的顺序在AXI4协议的规定下必须为:WDATA0_0,WDATA0_1,WDATA1_0,WDATA1_1,WDATA2_0…

【3】PyQt文本和图片

1. 文本控件 文本控件是QLabel from PyQt5.QtWidgets import QWidget, QApplication, QLabel import sys# 1.创建应用程序 app QApplication(sys.argv)# 2.创建窗口 w QWidget()# 修改窗口标题 w.setWindowTitle(文本展示)# ---------------------------------------------…

从0开始学Spring、Springboot总结笔记(持续更新中~)

文章目录 一.基于SpringBoot进行Web开发入门1.IDEA编译器中创建springboot工程扩展&#xff1a;如何解决pom.xml文件中“找不到Maven插件”的问题&#xff1f; 2.Springboot项目如何编写请求类和请求方法并启动访问编写请求类和请求方法启动Springboot访问 一些学习资源参考 一…

超完整的mysql安装配置方法(包含idea和navicat连接mysql,并实现建表)

mysql安装配置方法 1、下载mysql2、解压到指定的安装目录3、配置初始化文件my.ini4、配置用户变量和系统变量5、初始化mysql6、安装mysql服务并启动修改密码7、使用idea连接mysql8、使用Navicat可视化工具连接mysql&#xff0c;并实现新建数据库&#xff0c;新建表 1、下载mysq…

pta模拟题(C语言7-26 整除光棍、7-27 稳赢、7-28 查验身份证、7-29 出生年、7-30 点赞)

7-26 整除光棍 这里所谓的“光棍”&#xff0c;并不是指单身汪啦~ 说的是全部由1组成的数字&#xff0c;比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如&#xff0c;111111就可以被13整除。 现在&#xff0c;你的程序要读入一个整数x&#xff0…

CentOS增加虚拟内存 (Linux增加内存)

前言 因为囊中羞涩不敢言&#xff0c;所以内存只有2G&#xff0c;项目在运行的时候&#xff0c;占用的内存已经报表&#xff0c;所以有的时候就会出现宕机的情况发生&#xff0c;后面发现可以通过使用增加虚拟内存空间&#xff0c;来增加内存容量。 下面进入正题&#xff0c;讲…

APOLLO自动驾驶技术沙龙:未来已来,共创智能交通新时代

在这次Apollo会议上&#xff0c;我深刻地感受到了人工智能自动驾驶技术领域的最新进展和未来趋势。作为一名从事软件开发工作的人员&#xff0c;我深感荣幸能够参加这次盛会。 前言 本次活动是百度Apollo社区工程师齐聚首钢Park&#xff0c;带来现场实操与技术分享。主要围绕Ap…

B027-MySQL增强

目录 多表查询为什么要用多表查询&#xff1f;笛卡尔积和内连接消除笛卡尔积外键数据库内连接练习左连接查询和右连接查询等值连接out join自连接子查询 数据操作(DML)数据的插入数据的删除数据的修改 数据库的备份与恢复Dos命令行窗口导出Dos命令行窗口导入Navicat导出Navicat…

【问题总结】Docker环境下,将Nacos版本2.0.4升级到2.2.3,操作留档 以及 踩坑记录

前记&#xff0c;鉴于nacos暴露的验证鉴权bug&#xff08;之前尝试解决但是没有完全解决&#xff01;&#xff0c;需要对公司之前架构留下来的老版本nacos进行升级 参考资料&#xff1a; https://nacos.io/zh-cn/blog/announcement-token-secret-key.html https://nacos.io/…

C++-内联函数

目录 一.什么是内联函数 1.内联函数的概念 2.内联函数的定义 二.C中引入内联函数的原因 三.什么样的函数适合被声明为内联呢&#xff1f; 四.面试题 一.什么是内联函数 1.内联函数的概念 以inline修饰的函数叫做内联函数&#xff0c;编译时C编译器会在调用内联函数的地方展开…

iptables入门

今天我的工作遇到了巡检网络配置的任务&#xff0c;这次巡检的主机都是运行十多年的机器&#xff0c;并不是新的firewalld&#xff0c;基本都是iptables&#xff0c;上学的时候以为这些都没人用&#xff0c;所以没有认真学习&#xff0c;现在需要用到了&#xff0c;所以写一篇文…

【Midjourney实战】| 新年礼盒元素设计

文章目录 1 初步提示词2 润色提示词3 提示词发散联想 这期实践任务&#xff0c;我们想去做一个新年礼盒的效果&#xff0c;最后我们想把不同元素拼在一起&#xff0c;方便后期进行新年的相关设计 1 初步提示词 提示词初步我们乍一想&#xff0c;肯定要包括主体元素礼盒 新年礼…

C# 雪花算法生成Id工具类

写在前面 传说自然界中并不存在两片完全一样的雪花的&#xff0c;每一片雪花都拥有自己漂亮独特的形状、独一无二&#xff1b;雪花算法也表示生成的ID如雪花般独一无二&#xff0c;该算法源自Twitter。 雪花算法主要用于解决分布式系统的唯一Id生成问题&#xff0c;在生产环境…

YOLOv8改进 | 2023 | FocalModulation替换SPPF(精度更高的空间金字塔池化)

一、本文介绍 本文给大家带来的改进是用FocalModulation技术来替换了原有的SPPF&#xff08;快速空间金字塔池化&#xff09;模块。FocalModulation是今年新提出的特征增强方法&#xff0c;它利用注意力机制来聚焦于图像中的关键区域&#xff0c;从而提高模型对这些区域的识别…

Python中检查字符串是否仅包含字母的多种方法:深入探究

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com 随着Python在数据处理和字符串操作方面的广泛应用&#xff0c;经常需要对字符串进行验证&#xff0c;确认其是否仅包含字母。本文将探讨Python中的多种方法来检查字符串是否只由字母组成&#xff0c;以及它们的应…

想要精确搜索商品详情?闲鱼电商API接口帮你实现!

闲鱼电商API接口是一种为开发者提供的强大工具&#xff0c;它能够帮助开发者轻松获取闲鱼平台上的商品信息&#xff0c;实现精确搜索商品详情功能。无论你是想要开发一个自有电商平台&#xff0c;还是需要定制商品搜索功能&#xff0c;闲鱼电商API接口都能够满足你的需求。 API…