【C++深入学习】日期类函数从无到有实现

news2024/9/24 11:25:44

零、本文思维导图

画板

一、前期准备

1.1 检查构造的日期是否合法

//Date.cpp
bool Date::CheckDate()
{
	if (_month < 1 || _month > 12
		|| _day < 1 || _day > GetMonthDay(_year, _month))
	{
		return false;
	}
	else
	{
		return true;
	}
}

Date::Date(int year, int month, int day)
{
	_year = year;
	_month = month;
	_day = day;
	//防止构造的日期有问题
	if (!CheckDate())
	{
		cout << "非法日期:" << endl;
		Print();
	}
}

1.2 获取某年的某月的总天数

  • 建议直接写在类里面作为成员函数:定义在类里面的成员函数默认是内联inline,而且该函数不仅短小,还会被频繁调用;
	int GetMonthDay(int year, int month)
	{
        assert(month > 0 && month < 13);//避免出现非法月份??????
		static int GetMonthDayArray[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (month == 2 && (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		//先判断是否为2月
		{
			return 29;//闰年
		}
		return GetMonthDayArray[month];
	}

1.3 打印函数

void Date::Print()
{
	cout << _year << "年" << _month << "月" << _day << "日" << endl;
}

二、日期+天数

2.1 operator+=

  • 进位:时间在向前先直接相加,日期不合法,减天加月,月满加年,直至日期合法。
  • 返回值:返回*this,所以使用引用返回。
  • 注意:这里是+=,而不是+a+1:a本身不变;a+=1:a本身是会变的。
//日期+天数:d1+=100
Date& Date::operator+= (int day)
{
    if(day < 0)
    {
        return *this-=(-day);//day为负数的情况
    }
	//正常+:2024/7/12+10=2024/7/22
	_day += day;
	while (_day > GetMonthDay(_year, _month))//判断日期是否非法
	{
		//时间在前进:
		_day -= GetMonthDay(_year, _month);//先减天
		++_month;//再加月,判断是否满月,满月进年
		if (_month == 13)
		{
			_year++;
			_month = 1;
		}
	}
	return *this;
}

2.2 operator+

  • 使用传值返回
  • 直接写:
//d1 + 100
Date Date::operator+ (int day)
{
	Date tmp = *this;//这里拷贝一份出来
	tmp._day += day;
	while (tmp._day > GetMonthDay(tmp._year, tmp._month))
	{
		tmp._day -= GetMonthDay(tmp._year, tmp._month);
		++tmp._month;
		if (tmp._month == 13)
		{
			tmp._year++;
			tmp._month = 1;
		}
	}
	return tmp;//这里就不能使用引用返回了,局部对象,出作用域就会销毁
}
  • 上面的是直接写的,也可以在写了operator+=后,+复用+=
//d1 + 100
Date Date::operator+ (int day)
{
	Date tmp = *this;//这里拷贝一份出来
	tmp += day;//复用+=
    
	return tmp;//这里就不能使用引用返回了,局部对象,出作用域就会销毁
}

三、日期-天数

3.1 operator-=

//d1 -= 100
Date& Date::operator-=(int day)
{
    if(day < 0)
    {
        return *this += (-day);//day是负数的情况
    }
	_day -= day;
	while (_day <= 0)//判断出非法日期
	{
		--_month;//先借月
		if (_month == 0)
		{
			--_year;
			_month = 12;
		}
		_day += GetMonthDay(_year, _month);//加上借来的
	}
	return *this;
}

3.2 operator-

  • 直接实现:
Date Date::operator-(int day)
{
	Date tmp = *this;
	tmp._day -= day;
	while (tmp._day<=0)
	{
		--tmp._month;
		if (tmp._month == 0)
		{
			tmp._month = 12;
			--tmp._year;
		}
		tmp._day += GetMonthDay(tmp._year, tmp._month);
	}
	return tmp;
}
  • -复用-=
//d1 - 100
Date Date::operator-(int day)
{
	Date tmp = *this;
	tmp -= day;
	return tmp;
}

3.3 两种复用对比

  1. -=复用-
Date Date::operator-(int day)
{
	Date tmp = *this;//拷贝1
	tmp._day -= day;
	while (tmp._day<=0)
	{
		--tmp._month;
		if (tmp._month == 0)
		{
			tmp._month = 12;
			--tmp._year;
		}
		tmp._day += GetMonthDay(tmp._year, tmp._month);
	}
	return tmp;//拷贝2
}

Date& Date::operator-=(int day)
{
	/*Date tmp = *this - day;
	*this = tmp;*/

	*this = *this - day;//赋值也是一种拷贝

	return *this;
}
// 拷贝的次数比第一种多
  1. -复用-=(相对较好)
//d1 -= 100
Date Date::operator-(int day)
{
	Date tmp = *this;//拷贝1
	tmp -= day;
	return tmp;//拷贝2
}
//-的拷贝次数都是一样的

Date& Date::operator-=(int day)//无拷贝
{
	_day -= day;
	while (_day <= 0)//判断出非法日期
	{
		--_month;//先借月
		if (_month == 0)
		{
			_month = 12;
			--_year;
		}
		_day += GetMonthDay(_year, _month);//加上借来的
	}
	return *this;//传引用返回
}
  • 两种operator-的拷贝次数一样;
  • 第二种的-=是自己实现的,全程无拷贝;但是第一种-=复用-:前面-的两次拷贝再加上自己本身的一次赋值拷贝。因此第二种相对较好。

四、日期比较

4.1 operator<

先判断所有<并将其归为一类,均为true

//<运算符的重载
bool Date::operator<(const Date& d)
{
	//true为一类
	if (_year < d._year)
	{
		return true;
	}
	else if (_year == d._year)
	{
		if (_month < d._month)
		{
			return true;
		}
		else if (_month == d._month)
		{
			if (_day < d._day)
			{
				return true;
			}
		}
	}
	//false为一类
	return false;
}

4.2 operator==

年月日均相等,则为true

//==运算符的重载
bool Date::operator==(const Date& d)
{
	return _year == d._year 
		&& _month == d._month 
		&& _day == d._day;
}

4.3 其他关系比较

在写了operator<(或者operator>)和operator=两个之后,就可以根据去翻等个侯总逻辑关系表示出其他的关系符。

  1. <=运算符的重载
//<=运算符的重载
bool Date::operator<=(const Date& d)
{
	//在写了前面两个之后:
	return *this < d || *this == d;
}
  1. >运算符的重载
//>运算符的重载
bool Date::operator>(const Date& d)
{
	return !(*this <= d);
}

  1. >=运算符的重载
//>=运算符的重载
bool Date::operator>=(const Date& d)
{
	return !(*this < d);
}
  1. !=运算符的重载
//!=运算符的重载
bool Date::operator!=(const Date& d)
{
	return !(*this == d);
}

五、++

  • 前置++用的比较多,而且拷贝比较少。
  • 重载++运算符时,有前置++和后置++,运算符重载函数名都是**operator++**,无法很好的区分。C++规定,后置++重载时,增加一个**int**形参,跟前置++构成函数重载,方便区分。

5.1 前置++

//1.前置++:d1.operator++()
Date& Date::operator++()//没有拷贝
{
	//Date tmp = *this;//可省略不写
    //复用 operator+=
	*this += 1;
	return *this;
}

5.2 后置++

//2.后置++:d1.operator++(0)(括号里面只要求整数)
Date Date::operator++(int)//有拷贝
{
	Date tmp = *this;//拷贝构造,用于返回
	*this += 1;
	return tmp;
}

六、-- (和++相似)

6.1 前置–

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

6.2 后置–

//2.后置--运算符重载
Date Date::operator--(int)
{
	Date tmp = *this;
    //复用 operator-=
	*this -= 1;
	return tmp;
}

七、日期-日期

计算两个日期之间相差的天数。

  • 法一:直接相减,非常繁琐而且容易出错,借月后从12月份开始而不是从1月份开始;
  • 法二:从年初开始,做年的减法和月日的减法,如下图条框内做减法。

  • 法三:

思路:在生活中,我们有些人算数有一种习惯,例如计算8 + 4,我们就会数:9,10,11,12,数到四个数。这里也是用的这个思路。从小的日期一直数到大的日期,同时用计数器进行计数。

注意:这里我们需要判断两个日期谁大谁小。

//日期-日期 d1 - d2
int Date::operator-(const Date& d)
{
	int flag = 1;//flag为1:表示返回正值
	//假设
	Date max = *this;
	Date min = d;
	if (*this < d)//假设不成立
	{
		max = d;//更正min、max
		min = *this;
		flag = -1;//假设错误,表示返回负值,返回的总天数*flag就可以得到正数的两天差差值
	}
	int n = 0;//相当于一个计数器
	while (min != max)
	{
		++min;//开始从min数到max
		++n;//开始计数
	}
	return n * flag;//返回的正差值天数
}

八、流插入和流提取

scanfprintf不能输入输出自定义类型例如类类型,间接输入输出又不方便,直接确定的是内置类型。

根据下面两图发现:coutostream类型的对象,cinistream类型的对象。内置类型能够直接使用是因为istreamostream里面已经用operator重载好这些操作符了,他们可以自动识别类型(如内置类型)都是因为函数重载。

如果想自主输入日期和提取日期,就可以自己实现重载<<>>操作符。

8.1 流插入运算符重载

8.1.1 实现自主输出

如果想要自己重载函数实现下面的效果:输出d1到控制台。

cout << d1;//日期类对象流入控制台(I/O流)
  1. 第一种写法(错误写法):写成成员函数
//cout是ostream类型的对象
void Date::operator<<(ostream& out)
{
	out << _year << "年" << _month << "月" << _day << "日" << endl;
}
  • 报错结果:
//test.cpp
void TestDate()
{
	Date d1, d2;

	cout << d1;//error:这里为什么用不了?
    //error: message : 尝试匹配参数列表“(std::ostream, Date)”时。
}
  • 分析报错原因:参数无法匹配:cout本来应该匹配ostream类,但是成员函数第一个隐含的参数是this指针也就是日期类,d1本来应该匹配日期类,现在匹配的是ostream类。
  • 改进:根据上面的分析,做了些许test.cpp文件的改进。虽然可以运行但是现在这段代码和我们本来的意义背道而驰。而且this指针又因const保护无法变动,所以舍弃成员函数的方法。
void TestDate5()
{
	Date d1, d2;

	//cout << d1;

	d1 << cout;
	d1.operator<<(cout);
}
  1. 第二种写法:
  • 写成全局函数,为了访问Date类里面的成员变量,我们可以将private换成public 或者 提供get函数。
//测试全局函数operator<<
void TestDate6()
{
	Date d1, d2;

	cout << d1;
	operator<<(cout, d1);
}
  • 在类外面访问类里面的内容,最好的办法就是加一个友元函数声明**friend**,位置随意。
//Date.h
//在类里面加入friend,友元函数声明
friend void operator<<(ostream& out, const Date& d);//d加const是因为d不能被改变
//在类外面
void operator<<(ostream& out, const Date& d);
//这样就可以在类外面访问类里面的私有成员了

//Date.cpp
void operator<<(ostream& out, const Date& d)//全局函数
{
	out << d._year << "年" << d._month << "月" << d._day << "日" << endl;	
}

8.1.2 实现自主连续输出

如果想要实现连续输出,就像下面一样的效果:

cout << d1 << d2;//需要从左往右结合
// cout << d1,返回左操作数cout,cout << d2,整体表达式的返回值就是左操作数cout
// 所以全局函数的返回值用 ostream& 来接收

根据前面的代码和逻辑,可以类比地写出本段代码如下:

//Date.h
//在类里面加入friend,友元函数声明
friend ostream& operator<<(ostream& out, const Date& d);
 //在类外面
ostream& operator<<(ostream& o2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ut, const Date& d);
//这样就可以在类外面访问类里面的私有成员了

//Date.cpp
ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << "年" << d._month << "月" << d._day << "日" << endl;	
	return out;
}
//本段代码的思路总结:
//写多少个operator就是多少个全局函数调用,
//全局函数里面需要调用类里面的私有成员变量,
//因此我们就是用了友元函数声明

8.2 流提取运算符重载

//流提取运算符重载
//Date.h
//在类里面加入friend,友元函数声明
friend istream& operator>>(istream& in, Date& d);//d不加const:流对象不支持拷贝构造
//在类外面
istream& operator>>(istream& in, Date& d);

//Date.cpp
istream& operator>>(istream& in, Date& d)
{
    //改进:检查是否为非法日期
    while(1)//进入循环,先检查日期是否非法,若非法,则重新输入
    {
        cout << "请依次输入年月日:";//流提取里面使用cout这样是不会乱的
    	in >> d._year >> d._month >> d._day;//不用cin,避免流错乱        
         if(!d.CheckDate())
         {
             cout<<"输入日期非法:";
             d.Print();
             cout<<"请重新输入!!!"<<endl;
         }   
        else
         {
             break;
         }
    }
    return in;
}

在此之前,我们就知道cincout是有绑定关系的,因为C++兼容C语言,缓冲区就会保持同步,所以在进行刷新的时候会把printf的缓冲区进行刷新,coutprintf多次混用就不会乱。所以:如果printf没有进行刷新,那么cout就在刷新自己之前先刷新printf

cincout也是同理,在cin进行I/O操作之前会将cout的缓冲区进行刷新。

但是刷新缓冲区会牺牲效率,刷新缓冲区也会有一定的要求,例如遇到换行符会主动进行刷新或者程序结束时会刷新。

如果在IO需求比较高的地方,就可以加入三行代码提高C++的IO效率。

#include <iostream>
using namespace std;

int main()
{
	// 在IO需求比较高的地方,比如部分大量输入的竞赛题中,
    // 加上以下的三行代码,就可以提高C++的IO效率。
	ios_base::sync_with_stdio(false);//关闭C语言的环境
	cin.tie(nullptr);//原本默认cin是与cout进行绑定的,nullptr使得cin和谁都不进行绑定
	cout.tie(nullptr);//cout也与谁都不你行绑定了

	return 0;
}

九、所有代码

Date.h

#pragma once
#include<iostream>
#include<assert.h>
using namespace std;
 
class Date
{
    //友元函数声明
    friend ostream& operator<<(ostream& out, coonst Date& d);
    friend istream& operator>>(istream& in, Date& d);

public:
    bool CheckDate() const;
    void Print() const;

    //默认是inline
	//获取具体某一年某一月的天数
	int GetMonthDay(int year, int month) const
	{
		assert(month > 0 && month < 13);
        // 因为该函数会经常调用,但是数组的值一直是不需要变化的,因此可以使用静态数组
		// 好处是在静态区只会创建一份变量
		static int GetMonthDayArray[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
		//先判断是否为2月
		{
			return 29;//闰年
		}
		return GetMonthDayArray[month];
	}
	// 构造函数
    //Date(int year = 1900, int month = 1,int day = 1);
	Date(int year, int month, int day);
	// 拷贝构造函数
	// d2(d1)
	Date(const Date& d);
	// 赋值运算符重载
	// d2 = d3 -> d2.operator=(&d2, d3)

    //比较大小可以加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=(const Date& d);

	// 日期+=天数
	Date& operator+=(int day);
	// 日期+天数
	Date operator+(int day) const;

	// 日期-天数
	Date operator-(int day) const;
	// 日期-=天数
	Date& operator-=(int day);

    //不加const,因为需要成员变量本身的改变
	// 前置++
	Date& operator++();
	// 后置++
	Date operator++(int);
 
	// 后置--
	Date operator--(int);
	// 前置--
	Date& operator--();
 
	// 日期-日期 返回天数
	int operator-(const Date& d) const;
private:
	int _year;
	int _month;
	int _day;
};
//只要不修改成员变量的都建议加上const
713日讲了

Date.cpp

#define _CRT_SECURE_NO_WARNINGS 1
#include "Date.h"

bool Date::CheckDate() const
{
    if(_month < 1||_month > 12
    || _day < 1 || _day > GetMonthDay(_year ,_month))
    {
        return false;
    }
    else
    {
        return true;
    }
}

// 构造函数
Date::Date(int year, int month, int day)
{
	_year = year;
	_month = month;
	_day = day;

    if(!CheckDate())//判断日期是否合法
    {
        cout<<"非法日期:";
        Print();
    }
}
// 拷贝构造函数
// d2(d1)
Date::Date(const Date& d)
{
	_year = d._year;
	_month = d._month;
	_day = d._day;
}
// 赋值运算符重载
// d2 = d3 -> d2.operator=(&d2, d3)
Date& Date::operator=(const Date& d)
{
	_year = d._year;
	_month = d._month;
	_day = d._day;
 
	return *this;
}
 
// >运算符重载
bool Date::operator>(const Date& d) const
{
	if (_year > d._year)
		return true;
	else if (_year == d._year)
	{
		if (_month > d._month)
			return true;
		else if (_month == d._month)
		{
			if (_day > d._day)
				return true;
		}
	}
	return false;
}
// ==运算符重载
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 || *this == d;
}
// <运算符重载
bool Date::operator < (const Date& d) const
{
	return !(*this >= d);
}
// <=运算符重载
bool Date::operator <= (const Date& d) const
{
	return !(*this > d);
}
// !=运算符重载
bool Date::operator != (const Date& d) const
{
	return !(*this == d);
}
 
 
// 日期+=天数
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 temp(*this);
//	temp += day;
//	return temp;
//}
 
// 日期+天数 ---直接实现
Date Date::operator+(int day) const
{
	Date temp(*this);
	temp._day += day;
	while (temp._day > GetMonthDay(_year, _month))
	{
		temp._day -= GetMonthDay(temp._year, temp._month);
		++temp._month;
		if (temp._month == 13)
		{
			++temp._year;
			temp._month = 1;
		}
	}
	return temp;
}
// 日期-=天数
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 temp(*this);
	Date temp(*this);
	temp -= day;
 
	return temp;
}
 
 //日期-天数 ---直接实现
//Date Date::operator-(int day) const
//{
//	//Date temp(*this);
//	Date temp(*this);
//	temp._day -= day;
//	while (temp._day <= 0)
//	{
//		--temp._month;
//		if (temp._month == 0)
//		{
//			--temp._year;
//			temp._month = 12;
//		}
//		temp._day += GetMonthDay(temp._year, temp._month);
//	}
//	return temp;
//}
 
// 前置++
Date& Date::operator++()
{
	*this += 1;
	return *this;
}
// 后置++
Date Date::operator++(int)
{
	Date temp(*this);
	*this += 1;
	return temp;
}
// 后置--
Date Date::operator--(int)
{
	Date temp(*this);
	*this -= 1;
	return temp;
}
// 前置--
Date& Date::operator--()
{
	*this -= 1;
	return *this;
}
 
 
// 日期-日期 返回天数
int Date::operator-(const Date& d) const
{
	int flag = 1;
	Date max = *this;
	Date min = d;
	if (*this < d)
	{
		flag = -1;
		max = d;
		min = *this;
	}
	int n = 0;
	while (min != max)
	{
		min++;
		n++;
	}
	return n * flag;
}

喜欢的uu记得三连支持一下哦!

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

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

相关文章

3.6 排序

在第一趟排序之后&#xff0c;一定能把数据表中最大或最小元素放在其最终位置上的排序算法是&#xff08; &#xff09;。 A. 冒泡排序 B. 直接插入排序 C. 快速排序 D. 归并排序 正确答案是 A。 解析 第i趟冒泡排序是从第1个元素到第n-i1个元素依次比较相邻两个元素的关键字&a…

0、Typescript学习

1、变量声明 let a:number100 2、常量 const b:number200 3、判断变量的类型 //number 表示数值类型&#xff0c;包括整数和浮点数 let a:number100 console.log(typeof a) 4、定义数组 let arr1:number[][1,2,3]console.log(arr1[0]) 5、定义函数 &#xff08;1&…

PVN3D(一)代码框架

在windows上配置pvn3d的环境一直配不成功&#xff0c;主要卡在了与C联合编译上&#xff0c;不知道如何处理了。索性先看看代码&#xff0c;竟然发现与论文中的代码对应上了。希望这一段时间把环境配置好。 1.论文中的网络结构 1.RGB图像特征&#xff0c;通过CNN提取特征。深度…

【前端面试】leetcode指针解法javascript

最大盛水 https://leetcode.cn/problems/container-with-most-water/ var maxArea = function(height) {// 左右指针靠拢let left = 0;let right = height.length-1;let maxArea = 0; while(left<right){// 计算出 当前的容积 与最大容积比较,取出最大的const currentAre…

牛客周赛 Round 58(ABCDF)

目录 A.会赢吗&#xff1f; B.能做到的吧 C.会赢的&#xff01; D.好好好数 F.随机化游戏时间 A.会赢吗&#xff1f; 思路&#xff1a; 签到题&#xff0c;比大小 void solve() {double a,b;cin>>a>>b;if(a>b) cout<<"NO";else cout<&…

前端请求的路径baseURL怎么来的 ?nodejs解决cors问题的一种方法

背景&#xff1a;后端使用node.js搭建&#xff0c;用的是express 前端请求的路径baseURL怎么来的 &#xff1f; 前后端都在同一台电脑上运行&#xff0c;后端的域名就是localhost&#xff0c;如果使用的是http协议&#xff0c;后端监听的端口号为3000&#xff0c;那么前端请求…

pdf怎么去水印?5个实用去水印方法新手必看(保姆级攻略)

pdf怎么去水印&#xff1f;在日常的办公工作生活中&#xff0c;我们常常需要使用PDF文件。pdf格式文件非常流行&#xff0c;因为它兼具稳定性和安全性。但是&#xff0c;有时我们从网上下载的pdf文件会带有水印&#xff0c;这些水印不仅影响了文件的美观&#xff0c;还影响了别…

turbovnc 服务端、客户端安装

turbovnc 可以方便地远程登录带界面的linux系统&#xff0c;比如xbuntu、kali等&#xff1b;远程windows11系统&#xff0c;经过亲身测试体验&#xff0c;感觉还是不如windows自带的rdp服务&#xff08;mstsc命令连接&#xff09;好用。 一、安装客户端 下载最新版本的客户端…

Java:位运算符,移位运算

一 位运算符 1.按位与------ & 运算法则&#xff1a; 2.按位或------ | 运算法则&#xff1a; 3.按位异或------ ^ 运算法则&#xff1a; 4.按位取反------ ~ 运算法则&#xff1a; 如果该位为 0 则转为 1, 如果该位为 1 则转为 0 二 移位运算 1.左移 << 运…

数据结构 双向链表

初始化 创建 遍历以及头插

Ubuntu 24.04 安装 英特尔工具包 Intel® Toolkits

目录 1.采用用户界面 GUI 安装英特尔基本工具包 Intel oneAPI Base Toolkit 1.1 下载离线英特尔基本工具包 1.2 安装英特尔基本工具包 1.3 英特尔基本工具包 Intel oneAPI Base Toolkit 环境设置 2.安装英特尔高性能计算工具包 Intel HPC Toolkit 2.1 下载离线英特尔高性…

学习大数据DAY52 Docker中的Mysql主从配置

Mysql 数据库主从同步 上机练习 1 容器生成命令 压缩包获取镜像 docker image load -i /root/mysql.tar 创建并开启两个镜像&#xff1a; docker run --name mysql1 -d -p 3333:3306 \ -v /opt/mysql1/conf:/etc/mysql/conf.d/ \ -v /opt/mysql1/data:/var/lib/mysql \…

精选整理!市面上7款AI论文生成器一键自动生成论文!

在当今学术研究和写作领域&#xff0c;AI技术的迅猛发展为研究人员提供了极大的便利。特别是AI论文自动生成助手&#xff0c;它们不仅能够提高写作效率&#xff0c;还能帮助生成高质量的论文内容。本文将详细介绍市面上7款超好用的AI论文生成器&#xff0c;并特别推荐千笔-AIPa…

kubernetes中的ParallelizeUntil()框架源码解读与使用

概述 摘要&#xff1a;本文从源码层面解读了kubernetes源码中常用的workqueue.ParallelizeParallelizeUntil()框架的源码实现&#xff0c;并且本文也将举例说明了workqueue.ParallelizeUntil()方法的典型使用场景。 正文 说明&#xff1a;基于 kubernetes v1.18.0 源码分析 …

Scratch教师节:给老师的一封信

小虎鲸Scratch资源站-免费Scratch作品源码,素材,教程分享平台! 【Scratch教师节特别献礼】—— 给老师的一封信&#xff1a;编程之光&#xff0c;照亮梦想之路 在这个金秋送爽、硕果累累的季节里&#xff0c;我们迎来了一个特别而温馨的日子——教师节。在这个充满感激与敬意的…

交叉编译概念

交叉编译概念 目录 交叉编译概念1. 什么是交叉编译2. 交叉编译的作用3. 交叉编译器4. 交叉编译工具链5. 交叉编译的一般步骤6. 交叉编译实例 1. 什么是交叉编译 交叉编译是指在一个平台上编译代码&#xff0c;使其能够在另一个不同的平台上运行的过程。这种编译方式通常用于开…

深入探索JDBC:Java数据库连接技术详解与实战应用

Java Database Connectivity&#xff08;JDBC&#xff09;是Java语言中用于访问关系型数据库的标准接口。它定义了一组API&#xff0c;使得Java程序能够以统一的方式连接、访问和操作不同的关系型数据库。JDBC不仅简化了数据库操作&#xff0c;还提高了Java应用程序的可移植性和…

抢先看:2024云栖大会体验攻略

这是一场「AI」奇妙之旅。 2024云栖大会定档 9月19日&#xff01; 期待与你在 杭州云栖小镇 共度一场为期3天的科技盛会 三日主论坛 400分论坛 与并行话题 4万平米 智能科技展区 免费领取云栖大会门票 怎么看、怎么玩、怎么逛 超长干货攻略奉上&#xff0c;请查收 ⬇️…

将OpenHarmony RK设备散包镜像打包为一个整包

本篇文章教大家使用瑞芯微的Linux_Pack_Firmware工具将rk设备的多个镜像文件打包为一个固件。首先感谢大佬AlgoIdeas开源的打包工具&#xff0c;开源地址&#xff1a;https://gitee.com/openharmony-driver/ril_adapter 接下来进行演示&#xff0c;下面我们使用OpenHarmony 4.…

js运算符----三元运算符

&#xff1f;前为真就执行&#xff1f;号后面的&#xff0c;为假就执行&#xff1a;号后边的 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge…