【C++】:日期类实现

news2024/9/24 1:17:09

朋友们、伙计们,我们又见面了,本期来给大家解读一下有关Linux的基础知识点,如果看完之后对你有一定的启发,那么请留下你的三连,祝大家心想事成!

C 语 言 专 栏:C语言:从入门到精通

数据结构专栏:数据结构

个  人  主  页 :stackY、

C + + 专 栏   :C++

Linux 专 栏  :Linux

目录

前言:

1. 基本构造

2. 基础运算符重载

3. 进阶运算符重载

3.1 日期+天数

3.2 日期-天数

3.3 日期+、-天数的优化版本

3.4 前置++、后置++、前置--、后置--

3.5 日期与日期相差天数

4. 流提取、流插入运算符重载

4.1 流插入

完整的优化代码:

4.2 流提取

5. 完整代码


前言:

承接上篇的类和对象本期我们来实现一下日期类,顺便再来回顾一下构造函数和运算符的重载,关于基本的运算符重载就不做过多的解释,之前没提到过的会在这里重点解释。

1. 基本构造

日期类的实现我们采用分文件来进行实现:

在头文件 Date.h中实现日期类的基本框架

在源文件 Date.cpp中实现框架逻辑

在源文件 Test.cpp中实现测试逻辑

日期类的基本创建只需要写出构造函数和打印函数即可,因为日期类中没有资源的创建与释放,所以编译器自动生成的析构函数拷贝构造以及&运算符重载足够使用。

头文件 :Date.h

//日期类
class Date
{
public:
	//不涉及内部数据的修改的函数可以加上const修饰
	 
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);

	//打印函数
	void Print() const;
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

源文件:Date.cpp

//拷贝构造函数(全缺省)
Date::Date(int year, int month, int day)
{
	_year = year;
	_month = month;
	_day = day;
}

//打印函数
void Date::Print() const
{
	cout << _year << "/" << _month << "/" << _day << endl;
}

2. 基础运算符重载

基础运算符的重载包括==、!=、<、<=、>、>=,这几个运算符重载比较简单,在这里就不做解析。

头文件:Date.h

//日期类
class Date
{
public:
	//不涉及内部数据的修改的函数可以加上const修饰
	 
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);

	//打印函数
	void Print() const;

	//==运算符重载
	bool operator==(const Date& d) const;
	//!=运算符重载
	bool operator!=(const Date& d) const;
	//<运算符重载
	bool operator<(const Date& d) const;
	//<=运算符重载
	bool operator<=(const Date& d) const;
	//>运算符重载
	bool operator>(const Date& d) const;
	//>=运算符重载
	bool operator>=(const Date& d) const;

private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

源文件 :Date.cpp

//==运算符重载
bool Date::operator==(const Date& d) const
{
	return _year == d._year
		&& _month == d._month
		&& _day == d._day;
}
//!=运算符重载
bool Date::operator!=(const Date& d) const
{
	return !(*this == d);
}
//<运算符重载
bool Date::operator<(const Date& d) const
{
	if (_year < d._year)
	{
		return true;
	}
	else if (_year == d._year && _month < d._month)
	{
		return true;
	}
	else if (_year == d._year && _month == d._month && _day < d._day)
	{
		return true;
	}
	else
	{
		return false;
	}
}
//<=运算符重载
bool Date::operator<=(const Date& d) const
{
	return *this == d || *this < d;
}
//>运算符重载
bool Date::operator>(const Date& d) const
{
	return !(*this <= d);
}
//>=运算符重载
bool Date::operator>=(const Date& d) const
{
	return !(*this < d);
}

3. 进阶运算符重载

基础的运算符重载只能满足一部分的需求,还需要对日期的加减。

3.1 日期+天数

一个日期+一个天数即可得到另外的一个日期,这里就存在一个天数满了进位月份,月份满了进位年份,那么就需要一个另外的函数来获取某一月的天数。

获取天数函数:

//获取某一个月的天数
int Date::GetMonthDay(int year, int month) const
{
	const static int MonthArray[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (month == 2
		&& (year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
	{
		return 29;
	}
	return MonthArray[month];
}

 首先判断是否为闰年,然后根据月份返回相对应的天数。

日期+天数代码:

头文件:Date.h

//日期类
class Date
{
public:
    //拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);
	//获取某一个月的天数
	int GetMonthDay(int year, int month) const;
	//+=运算符重载
	Date& operator+=(int day);
	//+运算符重载
	Date operator+(int day) const;
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

源文件:Date.cpp


//获取某一个月的天数
int Date::GetMonthDay(int year, int month) const
{
	const static int MonthArray[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (month == 2
		&& (year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
	{
		return 29;
	}
	return MonthArray[month];
}
//+=运算符重载
Date& Date::operator+=(int day)
{
	_day += day;
	//判断天数的合理性
	while (_day > GetMonthDay(_year, _month))
	{
		_day -= GetMonthDay(_year, _month);
		++_month;  //天满了进位月份
		if (_month == 13)
		{
			++_year;   //月份满了进位年份
			_month = 1;
		}
	}
	return *this;
}
//+运算符重载
Date Date::operator+(int day) const
{
	//构造一个新的Date
	Date tmp(*this);
	tmp += day;
	return tmp;
}

3.2 日期-天数

头文件:Date.h

//日期类
class Date
{
public:
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);
	//获取某一个月的天数
	int GetMonthDay(int year, int month) const;
	//-=运算符重载
	Date& operator-=(int day);
	//-运算符重载
	Date operator-(int day) const;
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

源文件:Date.cpp

//获取某一个月的天数
int Date::GetMonthDay(int year, int month) const
{
	const static int MonthArray[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (month == 2
		&& (year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
	{
		return 29;
	}
	return MonthArray[month];
}
//-=运算符重载
Date& Date::operator-=(int day)
{
	_day -= day;
	while (_day <= 0)
	{
		//向月份借位
		--_month;
		if (_month == 0)
		{
			//向年份借位
			--_year;
			_month = 12;
		}
		_day += GetMonthDay(_year, _month);
	}
	return *this;
}
//-运算符重载
Date Date::operator-(int day) const
{
	Date tmp(*this);
	tmp -= day;
	return tmp;
}

 3.3 日期+、-天数的优化版本

上面实现的这两个运算符重载还是有一定的缺陷的,万一有的人在+天数时传递负值就会出现问题,如果有人在-天数的时候传递负值也是会出现bug,那么就需要再次进行优化。

当使用日期+天数时传递负值直接复用-=操作 

当使用日期-天数时传递负值直接复用+=操作 

//+=运算符重载
Date& Date::operator+=(int day)
{
	//负值天数操作
	if (day < 0)
	{
		return *this -= (-day);
	}
	_day += day;
	//判断天数的合理性
	while (_day > GetMonthDay(_year, _month))
	{
		_day -= GetMonthDay(_year, _month);
		++_month;  //天满了进位月份
		if (_month == 13)
		{
			++_year;   //月份满了进位年份
			_month = 1;
		}
	}
	return *this;
}

//-=运算符重载
Date& Date::operator-=(int day)
{
	//负值天数操作
	if (day < 0)
	{
		return *this += (-day);
	}
	_day -= day;
	while (_day <= 0)
	{
		//向月份借位
		--_month;
		if (_month == 0)
		{
			//向年份借位
			--_year;
			_month = 12;
		}
		_day += GetMonthDay(_year, _month);
	}
	return *this;
}

3.4 前置++、后置++、前置--、后置--

上篇的文章中提到过前置和后置的区别就是后置++多了一个int参数

头文件:Date.h

//日期类
class Date
{
public:
	//前置++运算符重载
	Date& operator++();
	//后置++运算符重载
	Date operator++(int) const;
	//前置--运算符重载
	Date& operator--();
	//后置--运算符重载
	Date operator--(int) const;
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

源文件:Date.cpp

//前置++运算符重载
Date& Date::operator++()
{
	*this += 1;
	return *this;
}
//后置++运算符重载
Date Date::operator++(int) const
{
	Date tmp(*this);
	tmp += 1;
	return tmp;
}
//前置--运算符重载
Date& Date::operator--()
{
	*this -= 1;
	return *this;
}
//后置--运算符重载
Date Date::operator--(int) const
{
	Date tmp(*this);
	tmp -= 1;
	return tmp;
}

3.5 日期与日期相差天数

日期与日期相差天数也是使用-的运算符重载,日期-日期这里可以直接减,也可以使用两个日期同时减去2000年1月1日,然后根据差值计算天数,需要注意的是日期-日期是会出现负数的。还有一种比较简单的方法计数法:设置一个标志值记录正负,然后记录两个日期当中最大的一个日期,然后设置一个计数值,将小日期加1,同时也将计数值加1,直到小日期加到和大日期相等,那么此时这个计数值就是它们之间相差的日期。

源文件:Date.cpp

//日期-日期
int Date::operator-(const Date& d) const
{
	Date dmax = *this;
	Date dmin = d;
	int flag = 1;  //记录正负
	//找出较大的日期
	if (*this < d)
	{
		dmax = d;
		dmin = *this;
		flag = -1;
	}
	//设置计数值
	int coutN = 0;
	while (dmin != dmax)
	{
		++dmin;
		++coutN;
	}
	//将差值再*记录值
	return coutN * flag;
}

4. 流提取、流插入运算符重载

如果我们使用cout来直接打印日期类的话是不能打印的,同样的使用cin来对日期类输入也是不支持的,因为日期类是不属于内置类型的,如果我们也要像内置类型一样使用cin和cout就需要对>>(流提取)<<(流插入)进行重载

cin是一个istream类中的对象,内置类型能使用流提取的原因就是库里面将内置类型都进行重载了。

cout是一个ostream类中的对象

4.1 流插入

我们要实现自定义类型的流插入就需要用到库里面的流插入来进行辅助:

//头文件:Date.h

//日期类
class Date
{
public: 
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);
	//打印函数

	//流插入
	void operator<<(ostream& out);

private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};


//源文件:Date.cpp
//流插入
void Date::operator<<(ostream& out)
{
	out << _year << "/" << _month << "/" << _day << endl;
}

如果这样子写的话会出现一个问题:我们正常调用会调用不了:

类成员函数的第一个参数是隐藏的this指针,所以正常调用的话跟重载的顺序不匹配:

实现为这样非要调用的话只需要将顺序换一下即可:

但是这样子调用又不符合日常调用习惯,所以我们需要将两个参数的位置调换,但是类成员函数的第一个函数是默认隐藏的,所以需要调换的话就需要写为全局运算符重载函数,但是设为全局又存在一个新的问题,类中的私有函数在类外面不能访问,这里有两种方法:

1. 使用单独的函数将年份、月份、天数都分别保存起来直接使用。

2. 将流插入运算符重载设置为友元函数

在这里我们使用第二种方法:

//头文件:Date.h
//日期类
class Date
{
	//友元声明
	friend void operator<<(ostream& out, const Date& d);

public:
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);
    //...
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

//流插入
void operator<<(ostream& out, const Date& dt);

//源文件:Date.cpp
//流插入
void operator<<(ostream& out, const Date& d)
{
	out << d._year << "/" << d._month << "/" << d._day << endl;
}

这样写的话还是存在一个小小的问题:每次输出的话只能一个一个日期类进行输出,不能一次性输出多个:

这个问题的主要原因是前面的输出d1是一个正常的运算符重载,而这个运算符重载的返回值又是void,而接下来的运算符重载不认识void类型,所以需要返回一个ostream类型才能完成下面的输出。

完整的优化代码:

头文件:Date.h

//日期类
class Date
{
	//友元声明
	friend ostream& operator<<(ostream& out, const Date& d);

public:
	//不涉及内部数据的修改的函数可以加上const修饰
	 
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);
	//...
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

//流插入
ostream& operator<<(ostream& out, const Date& d);

源文件:Date.cpp

//流插入
ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << "/" << d._month << "/" << d._day << endl;
	return out;
}

4.2 流提取

cin是一个istream类中的对象,所以我们可以借助istream来实现对于日期类的输入:

头文件:Date.h

//日期类
class Date
{
	//友元声明
	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);

public:
	//不涉及内部数据的修改的函数可以加上const修饰
	 
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);
    //...
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

//流插入
ostream& operator<<(ostream& out, const Date& d);
//流提取
istream& operator>>(istream& in, Date& d);

源文件:Dtae.cpp


//流插入
ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << "/" << d._month << "/" << d._day << endl;
	return out;
}
//流提取
istream& operator>>(istream& in, Date& d)
{
	in >> d._year >> d._month >> d._day;
	return in;
}

5. 完整代码

头文件:Date.h

#pragma once
#include <iostream>
using namespace std;

//日期类
class Date
{
	//友元声明
	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);

public:
	//不涉及内部数据的修改的函数可以加上const修饰
	 
	//拷贝构造函数(全缺省)
	Date(int year = 1949, int month = 10, int day = 1);
	//打印函数
	void Print() const;
	//获取某一个月的天数
	int GetMonthDay(int year, int month) const;

	//==运算符重载
	bool operator==(const Date& d) const;
	//!=运算符重载
	bool operator!=(const Date& d) const;
	//<运算符重载
	bool operator<(const Date& d) const;
	//<=运算符重载
	bool operator<=(const Date& d) const;
	//>运算符重载
	bool operator>(const Date& d) const;
	//>=运算符重载
	bool operator>=(const Date& d) const;

	//+=运算符重载
	Date& operator+=(int day);
	//+运算符重载
	Date operator+(int day) const;

	//-=运算符重载
	Date& operator-=(int day);
	//-运算符重载
	Date operator-(int day) const;

	//前置++运算符重载
	Date& operator++();
	//后置++运算符重载
	Date operator++(int) const;
	//前置--运算符重载
	Date& operator--();
	//后置--运算符重载
	Date operator--(int) const;

	//日期-日期
	int operator-(const Date& d) const;
private:
	int _year;  //年
	int _month; //月
	int _day;   //日
};

//流插入
ostream& operator<<(ostream& out, const Date& d);
//流提取
istream& operator>>(istream& in, Date& d);

源文件:Date.cpp

#define _CRT_SECURE_NO_WARNINGS 1
#include"Date.h"

//拷贝构造函数(全缺省)
Date::Date(int year, int month, int day)
{
	_year = year;
	_month = month;
	_day = day;
}
//打印函数
void Date::Print() const
{
	cout << _year << "/" << _month << "/" << _day << endl;
}

//==运算符重载
bool Date::operator==(const Date& d) const
{
	return _year == d._year
		&& _month == d._month
		&& _day == d._day;
}
//!=运算符重载
bool Date::operator!=(const Date& d) const
{
	return !(*this == d);
}
//<运算符重载
bool Date::operator<(const Date& d) const
{
	if (_year < d._year)
	{
		return true;
	}
	else if (_year == d._year && _month < d._month)
	{
		return true;
	}
	else if (_year == d._year && _month == d._month && _day < d._day)
	{
		return true;
	}
	else
	{
		return false;
	}
}
//<=运算符重载
bool Date::operator<=(const Date& d) const
{
	return *this == d || *this < d;
}
//>运算符重载
bool Date::operator>(const Date& d) const
{
	return !(*this <= d);
}
//>=运算符重载
bool Date::operator>=(const Date& d) const
{
	return !(*this < d);
}

//获取某一个月的天数
int Date::GetMonthDay(int year, int month) const
{
	const static int MonthArray[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (month == 2
		&& (year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
	{
		return 29;
	}
	return MonthArray[month];
}
//+=运算符重载
Date& Date::operator+=(int day)
{
	//负值天数操作
	if (day < 0)
	{
		return *this -= (-day);
	}
	_day += day;
	//判断天数的合理性
	while (_day > GetMonthDay(_year, _month))
	{
		_day -= GetMonthDay(_year, _month);
		++_month;  //天满了进位月份
		if (_month == 13)
		{
			++_year;   //月份满了进位年份
			_month = 1;
		}
	}
	return *this;
}
//+运算符重载
Date Date::operator+(int day) const
{
	//构造一个新的Date
	Date tmp(*this);
	tmp += day;
	return tmp;
}

//-=运算符重载
Date& Date::operator-=(int day)
{
	//负值天数操作
	if (day < 0)
	{
		return *this += (-day);
	}
	_day -= day;
	while (_day <= 0)
	{
		//向月份借位
		--_month;
		if (_month == 0)
		{
			//向年份借位
			--_year;
			_month = 12;
		}
		_day += GetMonthDay(_year, _month);
	}
	return *this;
}
//-运算符重载
Date Date::operator-(int day) const
{
	Date tmp(*this);
	tmp -= day;
	return tmp;
}

//前置++运算符重载
Date& Date::operator++()
{
	*this += 1;
	return *this;
}
//后置++运算符重载
Date Date::operator++(int) const
{
	Date tmp(*this);
	tmp += 1;
	return tmp;
}
//前置--运算符重载
Date& Date::operator--()
{
	*this -= 1;
	return *this;
}
//后置--运算符重载
Date Date::operator--(int) const
{
	Date tmp(*this);
	tmp -= 1;
	return tmp;
}

//日期-日期
int Date::operator-(const Date& d) const
{
	Date dmax = *this;
	Date dmin = d;
	int flag = 1;  //记录正负
	//找出较大的日期
	if (*this < d)
	{
		dmax = d;
		dmin = *this;
		flag = -1;
	}
	//设置计数值
	int coutN = 0;
	while (dmin != dmax)
	{
		++dmin;
		++coutN;
	}
	//将差值再*记录值
	return coutN * flag;
}

//流插入
ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << "/" << d._month << "/" << d._day << endl;
	return out;
}
//流提取
istream& operator>>(istream& in, Date& d)
{
	in >> d._year >> d._month >> d._day;
	return in;
}

朋友们、伙计们,美好的时光总是短暂的,我们本期的的分享就到此结束,欲知后事如何,请听下回分解~,最后看完别忘了留下你们弥足珍贵的三连喔,感谢大家的支持!

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Kafka和RabbitMQ的对比

Rabbitmq比kafka可靠&#xff0c;kafka更适合IO高吞吐的处理&#xff0c;比如ELK日志收集 Kafka和RabbitMq一样是通用意图消息代理&#xff0c;他们都是以分布式部署为目的。但是他们对消息语义模型的定义的假设是非常不同的。 a) 以下场景比较适合使用Kafka。如果有大量的事…

C#操作PPT动画窗格并插入音频文件的一些思路

目录 系统环境 基础配置 设计想法 关键代码 组件库引入 基础代码 核心代码 总结 系统环境 在 Windows Server 2019 操作系统上安装Office PowerPoint 2016或以上 安装 .netFramework4.7.1以上 开发工具 VS2019 语言 C# 基础配置 打开控制面板、管理工具、组件服务…

LabVIEW使用VI Package Manager(VIPM)下载和管理附加组件

LabVIEW使用VI Package Manager&#xff08;VIPM&#xff09;下载和管理附加组件 LabVIEW Tools Network和VI Package Manager&#xff08;VIPM&#xff09;使浏览&#xff0c;下载和管理LabVIEW附加组件变得容易。它具有软件包存储库&#xff0c;可以从桌面连接到软件包&…

基于差分进化优化的BP神经网络(分类应用) - 附代码

基于差分进化优化的BP神经网络&#xff08;分类应用&#xff09; - 附代码 文章目录 基于差分进化优化的BP神经网络&#xff08;分类应用&#xff09; - 附代码1.鸢尾花iris数据介绍2.数据集整理3.差分进化优化BP神经网络3.1 BP神经网络参数设置3.2 差分进化算法应用 4.测试结果…

基于原子搜索优化的BP神经网络(分类应用) - 附代码

基于原子搜索优化的BP神经网络&#xff08;分类应用&#xff09; - 附代码 文章目录 基于原子搜索优化的BP神经网络&#xff08;分类应用&#xff09; - 附代码1.鸢尾花iris数据介绍2.数据集整理3.原子搜索优化BP神经网络3.1 BP神经网络参数设置3.2 原子搜索算法应用 4.测试结果…

全面分析“找不到XINPUTI_3.dll无法继续执行代码”的5个解决方法总结

电脑已经成为我们生活&#xff0c;娱乐和工作中不可或缺的一部分&#xff0c;电子游戏是许多人的日常娱乐方式。然而&#xff0c;当我们沉浸在游戏的乐趣中时&#xff0c;有时会遇到一些问题&#xff0c;比如“找不到XINPUTI_3.dll”这样的错误提示。这种错误通常会导致游戏无法…

Android学习从入门到放弃(文末有福利)

移动开发早就不是最热门的程序员职业了&#xff0c;而且移动开发也并不是一个能够在短时间内轻松掌握的领域,需要我们有足够的耐心和毅力 作为一个在Android开发领域积累了不少经验的开发者&#xff0c;自己也看了不少书&#xff0c;也和不少前辈交流过&#xff0c;在这里分享一…

98 # jwt

什么是 jwt JSON WEB TOKEN (jwt) 是目前最流行的跨域身份验证解决方案。 解决问题&#xff1a;session 不支持分布式框架&#xff0c;无法支持横向扩展&#xff0c;只能通过数据库来保存会话数据实现共享&#xff0c;如果持久层失效就会出现认证失败。 优点&#xff1a;服务…

强化学习问题(二)--- ERROR: Failed building wheel for box2d-py

错误&#xff1a;Could not build wheels for box2d-py, which is required to install pyproject.toml-based projects pyproject.toml-based projects&#xff1a;意思是缺少依赖包&#xff0c;对于box2d就是缺少swig 注意&#xff1a;安装python对应的swig版本 解决1&…

2023 NewStarCTF --- wp

文章目录 前言Week1MiscCyberChefs Secret机密图片流量&#xff01;鲨鱼&#xff01;压缩包们空白格隐秘的眼睛 Web泄露的秘密Begin of UploadErrorFlaskBegin of HTTPBegin of PHPR!C!E!EasyLogin CryptobrainfuckCaesars SecertfenceVigenrebabyrsaSmall dbabyxorbabyencodin…

CART 算法——决策树

目录 1.CART的生成&#xff1a; &#xff08;1&#xff09;回归树的生成 &#xff08;2&#xff09;分类树的生成 ①基尼指数 ②算法步骤 2.CART剪枝&#xff1a; &#xff08;1&#xff09;损失函数 &#xff08;2&#xff09;算法步骤&#xff1a; CART是英文“class…

【Java 进阶篇】创建 HTML 注册页面

在这篇博客中&#xff0c;我们将介绍如何创建一个简单的 HTML 注册页面。HTML&#xff08;Hypertext Markup Language&#xff09;是一种标记语言&#xff0c;用于构建网页的结构和内容。创建一个注册页面是网页开发的常见任务之一&#xff0c;它允许用户提供个人信息并注册成为…

Logo制作方法大公开:初学者也能学会的Logo设计教程

Logo是品牌或企业的象征&#xff0c;一个好的Logo可以提升品牌的认知度和美誉度。但是&#xff0c;很多人在设计自己的Logo时都会遇到一些困难。今天&#xff0c;我们将为你揭示Logo制作的技巧和秘密&#xff0c;让你轻松设计出专业水准的Logo。 首先&#xff0c;你需要注册并登…

FPGA project : sobel

实验目标&#xff1a; sobel算法&#xff0c;处理100X100灰度图像&#xff1a;野火logo 边缘检测&#xff1a; 边缘检测&#xff0c;针对的是灰度图像&#xff0c;顾名思义&#xff0c;检测图像的边缘&#xff0c;是针对图像像素点的一种计算&#xff0c;目的是标识数字图像…

VM虚拟机扩容

背景介绍 在实现3D结构光扫描算法移植到嵌入式平台jetson Xavier NX时&#xff0c;需要在windows的电脑上安装VM虚拟机搭载Ubuntu&#xff0c;然后在Ubuntu 18.04上安装开发软件Nsight Eclipse Edition&#xff0c;在该集成开发软件上交叉编译jetson aarc64架构上可运行的文件…

SAE-J1939-21 (超8字节)多包数据----CAN传输协议

一、协议数据单元&#xff08;PDU&#xff09; 1. 优先级&#xff08;P&#xff09; 消息优先级可从最高 0&#xff08;000&#xff09;设置到最低 7&#xff08;111&#xff09;。 2. 保留位&#xff08;R&#xff09; 保留此位以备今后开发使用。 3. 数据页&#xff08;D…

中国移动咪咕、阿里云、华为“秀肌肉”,这届亚运会的“高光”不止比赛

文 | 智能相对论 作者 | 青月 竞技体育的发展&#xff0c;其实也可以看作是一部“技术进化史”。 在1924年的巴黎&#xff0c;广播首次进入奥运会&#xff0c;人们第一次可以通过报纸以外的方式了解奥运会。 1928年&#xff0c;在荷兰申办的阿姆斯特丹奥运会&#xff0c;高…

mi note3 刷入lineageos

下载 twrp TWRP是国外安卓爱好者开发的一款工具&#xff0c;全名为Team Win Recovery Project&#xff0c;主要作用包括刷机、备份 &#xff0c;救砖。 https://twrp.me/xiaomi/xiaomiminote3.html 一般下载最新版本&#xff0c;mi note 3对应 https://dl.twrp.me/jason/twrp-…

Hadoop----Azkaban的使用与一些报错问题的解决

1.因为官方只放出源码&#xff0c;并没有放出其tar包&#xff0c;所以需要我们自己编译&#xff0c;通过查阅资料我们可以使用gradlew对其进行编译&#xff0c;还是比较简单&#xff0c;然后将里面需要用到的服务文件夹进行拷贝&#xff0c;完善其文件夹结构&#xff0c;通常会…

Android笔记(二):JetPack Compose定义移动界面概述

一、JetPack Compose组件概述 JetPack Compose是Google公司在2021年正式推出的声明式UI工具包。Compose库用于开发原生Android应用界面。它取代传统XML文件配置界面&#xff0c;不需要界面编辑工具&#xff0c;而是采用强大Kotlin API以及函数搭建移动应用界面&#xff0c;代码…