【c++】——string类

news2024/9/24 7:19:45

在这里插入图片描述


🌱码云:一条咸鱼


目录

  • 🍉string类简介
  • 🍉string类的常用接口说明
    • 🍓string类对象常见构造函数
    • 🍓string类对象常见容量操作函数
    • 🍓string类对象访问及遍历操作函数
    • 🍓string类对象修改操作函数
    • 🍓string类非成员函数
  • 🍉深浅拷贝问题
  • 🍉string类模拟实现
  • 🍉总结

参考手册:cplusplus

🍉string类简介

C语言中,字符串是以\0结尾的一些字符的集合,为了操作方便,C标准库中提供了一些str系列的库函数, 但是这些库函数与字符串是分离开的,不太符合OOP的思想(面向对象编程),而且底层空间需要用户自己管理,稍不留神可能还会越界访问。

标准库中的string类:

  1. string是表示字符串的字符串类。
  2. 该类的接口与常规容器的接口基本相同,再添加了一些专门用来操作string的常规操作。
  3. string在底层实际是:basic_string模板类的别名,typedef basic_string string。
  4. 不能操作多字节或者变长字符的序列。

在使用string类时,必须包含string头文件。

🍉string类的常用接口说明

🍓string类对象常见构造函数

  1. string() :构造空的string类对象,即空字符串。

  2. string(const char* s):用字符串来构造string类对象。

  3. string(size_t n, char c):string类对象中包含n个字符c。

  4. string(const string&s) :拷贝构造函数。

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string arr1;
	string arr2("abcdef");
	string arr3(10, 'c');
	string arr4(arr2);
	cout << arr1 << endl << arr2 << endl << arr3 << endl << arr4;
	return 0;
}

运行结果:
在这里插入图片描述

🍓string类对象常见容量操作函数

size()返回字符串有效字符长度。

size_t size() const;

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string arr("apple");
	cout << arr.size() << endl;
	return 0;
}

运行结果:
在这里插入图片描述

lenth()返回字符串有效字符长度。

size_t length() const;

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string arr("apple");
	cout << arr.length() << endl;
	return 0;
}

运行结果:

capacity()返回空间总大小。

size_t capacity() const;

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string arr("apple");
	cout << arr.capacity() << endl;
	return 0;
}

运行结果:

empty()检测字符串是否为空串,是返回true,否则返回false。

bool empty() const;

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string arr1("apple");
	string arr2;
	if (arr1.empty())
		cout << "arr1 empty" << endl;
	else
		cout << "arr1 not empty" << endl;
	if (arr2.empty())
		cout << "arr2 empty" << endl;
	else
		cout << "arr2 not empty" << endl;
	return 0;
}

运行结果:
在这里插入图片描述

clear()清空有效字符。

void clear();

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string arr1("apple");
	cout << "begin : " << arr1 << endl;
	arr1.clear();
	cout << "end : " << arr1 << endl;
	return 0;
}

运行结果:
在这里插入图片描述

reserve()为字符串开辟空间。

void reserve (size_t n = 0);

示例:

int main()
{
	string arr1("apple");
	cout << arr1.capacity() << endl;
	arr1.reserve(arr1.capacity() * 2);
	cout << arr1.capacity() << endl;
	return 0;
}

运行结果:
在这里插入图片描述

resize()将有效字符的个数改成n个,多出的空间用字符c填充。

void resize (size_t n); 
void resize (size_t n, char c);

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string arr1("apple");
	cout << arr1.capacity() << endl;
	arr1.resize(arr1.capacity() * 2, 'X');
	cout << arr1.capacity() << endl << arr1 << endl;
	arr1.resize(arr1.capacity() / 2);
	cout << arr1.capacity() << endl << arr1 << endl;
	return 0;
}

运行结果:
在这里插入图片描述

注意:

  1. size()与length()方法底层实现原理完全相同,引入size()的原因是为了与其他容器的接口保持一致,一般情况下基本都是用size()。

  2. clear()只是将string中有效字符清空,不改变底层空间大小。

  3. reserve(size_t n = 0)函数为string预留空间,不改变有效元素个数,当reserve的参数小于string的底层空间总大小时,reserver不会改变容量大小。

  4. 当resize函数的n小于原来的有效字符个数时,resize会保留n个有效字符然后再后面加上/0,不会改变capacity的大小。当n大于原来的有效字符个数时,resize会在未初始化的空间上进行初始化,如果传了字符c就用c初始化,没有传就用\0初始化,resize在改变元素个数时,如果是将元素个数增多,可能会改变底层容量的大小,如果是将元素个数减少,底层空间总大小不变。

🍓string类对象访问及遍历操作函数

operator[]()返回pos位置的字符

	  char& operator[] (size_t pos);
const char& operator[] (size_t pos) const;

begin()获取一个字符的迭代器。

      iterator begin();
const_iterator begin() const;

end()获取最后一个字符下一个位置的迭代器。

      iterator end();
const_iterator end() const;

rbegin()获取最后一个字符的迭代器。

      reverse_iterator rbegin();
const_reverse_iterator rbegin() const;

rend()获取第一个字符的前一个位置的迭代器。

      reverse_iterator rend();
const_reverse_iterator rend() const;

tips :

  1. operator[]的使用我们通常直接使用[]的形式,如下代码两种形式都可以:
string s1("apple");
for (int i = 0; i < s1.size(); i++)
{
	cout << s1[i] << ' ';
}
cout << endl;
	
for (int i = 0; i < s1.size(); i++)
{
	cout << s1.operator[](i) << ' ';
}
cout << endl;
  1. 迭代器的begin-endrbegin-rend都是左闭右开的集合。
  2. 有迭代器的加持,在c++11中支持更简洁的范围for的新遍历方式,如下代码:
string s1("apple");
	for (auto e : s1)
		cout << e << ' ';
	cout << endl;

示例代码:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s1("hello world");
	cout << "operator[] : ";
	for (int i = 0; i < s1.size(); i++)
	{
		cout << s1[i];
	}
	cout << endl;

	cout << "begin : ";
	for (string::iterator bg = s1.begin(); bg != s1.end(); bg++)
	{
		cout << *bg;
	}
	cout << endl;

	cout << "rbegin : ";
	for (string::reverse_iterator rbg = s1.rbegin(); rbg != s1.rend(); rbg++)
	{
		cout << *rbg;
	}
	cout << endl;
	return 0;
}

运行结果:
在这里插入图片描述

🍓string类对象修改操作函数

push_back()在字符串尾插字符c

void push_back (char c);

append()在字符串后追加一个字符串str。

string& append (const string& str);
//追加字符串str从下标subpos位置开始的sublen个字符
string& append (const string& str, size_t subpos, size_t sublen);
string& append (const char* s);
//追加字符串s从下标0开始n个字符
string& append (const char* s, size_t n);
//追加n个c字符
string& append (size_t n, char c);
template <class InputIterator>
string& append (InputIterator first, InputIterator last);

operator+=在字符串后追加字符串。

string& operator+= (const string& str);
string& operator+= (const char* s);
string& operator+= (char c);

tips:s1 += "bear"s1.operator+=("bear")两种用法都可以,直接用+=更加便捷。

c_str()返回C格式字符串。

const char* c_str() const;

find()从字符串pos位置开始往后找字符c或字符串,返回该字符在字符串中的位置。没有则返回npos(-1)。

size_t find (const string& str, size_t pos = 0) const;
size_t find (const char* s, size_t pos = 0) const;
//从pos位置开始查找字符串s的前n个字符。
size_t find (const char* s, size_t pos, size_t n) const;
size_t find (char c, size_t pos = 0) const;

rfind从字符串pos位置开始往前找字符c,返回该字符在字符串中的位置。没有则返回npos(-1)。

size_t rfind (const string& str, size_t pos = npos) const;
size_t rfind (const char* s, size_t pos = npos) const;
//从pos位置开始查找字符串s的前n个字符。
size_t rfind (const char* s, size_t pos, size_t n) const;
size_t rfind (char c, size_t pos = npos) const;

substr()在str中从pos位置开始,截取n个字符,然后将其返回。

string substr (size_t pos = 0, size_t len = npos) const;

注意:

  • 当len大于str中pos位置后面剩余的字符时,那么就截取后面所有的字符。
  • 当不给len传参时,默认截取pos后面所有的字符。

示例代码:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s1("apple");
	s1.push_back('T');
	cout << s1 << endl;
	s1.append("abcd", 0, 4);
	cout << s1 << endl;
	s1 += "XXX";
	cout << s1 << endl;
	int ret1 = s1.find('T', 0);
	cout << ret1 << endl;
	int ret2 = s1.rfind('T', 12);
	cout << ret2 << endl;
	cout << s1.substr(5, 5) << endl;
	cout << s1.c_str() << endl;
	return 0;
}

运行结果:
在这里插入图片描述

🍓string类非成员函数

operator+将lhs和rhs组合成一个字符串。

string operator+ (const string& lhs, const string& rhs);
string operator+ (const string& lhs, const char*   rhs);
string operator+ (const char*   lhs, const string& rhs);
string operator+ (const string& lhs, char          rhs);
string operator+ (char          lhs, const string& rhs);

示例:

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s1("apple");
	string s2("bear");
	cout << s1 + s2 << endl;
	cout << operator+(s1, s2) << endl;
	return 0;
}

运行结果:
在这里插入图片描述

注意:尽量少用,因为传值返回,导致深拷贝效率低。

opereator>>输入运算符重载。

istream& operator>> (istream& is, string& str);

operator<<输出运算符重载。

ostream& operator<< (ostream& os, const string& str);

getline获取一行字符串(遇空格不结束)。

istream& getline (istream& is, string& str, char delim);
istream& getline (istream& is, string& str);

relational operators大小比较。

(1)
bool operator== (const string& lhs, const string& rhs);
bool operator== (const char*   lhs, const string& rhs);
bool operator== (const string& lhs, const char*   rhs);
(2)	
bool operator!= (const string& lhs, const string& rhs);
bool operator!= (const char*   lhs, const string& rhs);
bool operator!= (const string& lhs, const char*   rhs);
(3)	
bool operator<  (const string& lhs, const string& rhs);
bool operator<  (const char*   lhs, const string& rhs);
bool operator<  (const string& lhs, const char*   rhs);
(4)	
bool operator<= (const string& lhs, const string& rhs);
bool operator<= (const char*   lhs, const string& rhs);
bool operator<= (const string& lhs, const char*   rhs);
(5)	
bool operator>  (const string& lhs, const string& rhs);
bool operator>  (const char*   lhs, const string& rhs);
bool operator>  (const string& lhs, const char*   rhs);
(6)	
bool operator>= (const string& lhs, const string& rhs);
bool operator>= (const char*   lhs, const string& rhs);
bool operator>= (const string& lhs, const char*   rhs);

string类的接口众多,并不需要全都记住,我们只需要记得会用一些常见接口即可,有必要时可以直接去查看官方文档。

🍉深浅拷贝问题

浅拷贝:

也称位拷贝,编译器只是将对象中的值拷贝过来。如果对象中管理资源,最后就会导致多个对象共享同一份资源,当一个对象销毁时就会将该资源释放掉,而此时另一些对象不知道该资源已经被释放,以为还有效,所以当继续对资源进项操作时,就会发生发生了访问违规。

深拷贝:

深拷贝就是为了解决浅拷贝带来的问题,如果一个类中涉及到资源的管理,其拷贝构造函数、赋值运算符重载以及析构函数必须要显式给出,一般情况都是按照深拷贝方式提供。

示例:

#include <iostream>
#include <string>
using namespace std;
class mystring
{
public:
	mystring(const char* str = "")
	{
		if (str == nullptr)
		{
			_ptr = nullptr;
		}
		_ptr = new char[strlen(str) + 1];
		strcpy(_ptr, str);
	}
	~mystring()
	{
		if (_ptr)
		{
			delete[] _ptr;
			_ptr = nullptr;
		}
	}

private:
	char* _ptr;
};

int main()
{
	mystring s1("apple");
	mystring s2(s1);
	return 0;
}

如上代码,因为没有显示定义拷贝构造,默认的拷贝构造函数为浅拷贝,所以在析构时会出现内存泄漏。
运行结果:
在这里插入图片描述

因此,我们需要显示定义拷贝构造函数进行深拷贝,如下代码:

#include <iostream>
#include <string>
using namespace std;

class mystring
{
public:
	mystring(const char* str = "")
	{
		if (str == nullptr)
		{
			_ptr = nullptr;
		}
		_ptr = new char[strlen(str) + 1];
		strcpy(_ptr, str);
	}
	mystring(const mystring& s)
		:_ptr(new char[strlen(s._ptr) + 1])
	{
		strcpy(_ptr, s._ptr);
	}
	~mystring()
	{
		if (_ptr)
		{
			delete[] _ptr;
			_ptr = nullptr;
		}
	}

private:
	char* _ptr;
};

int main()
{
	mystring s1("apple");
	mystring s2(s1);
	return 0;
}

运行结果:
在这里插入图片描述

🍉string类模拟实现

简单模拟string类的功能,封装出一个自己的string类。

mystring.h:


#pragma once
#include <iostream>
#include <assert.h>

using namespace std;
namespace wzh {
	class mystring
	{
	private:
		friend ostream& operator<<(ostream& _cout, const wzh::mystring& s);
	public:
		typedef char* iterator;
	public:
		mystring(const char* str = "");
		mystring(const mystring& s);
		~mystring();
		void swap(mystring& s);
		mystring& operator=(mystring& s);
		iterator begin();
		iterator end();

		char& operator[](size_t index);
		const char& operator[](size_t index) const;

		size_t size() const;
		size_t capacity() const;
		bool empty() const;
		void clear();
		void push_back(char c);
		mystring& operator+=(char c);
		mystring& operator+=(const char* str);
		void append(const char* str);
		void resize(size_t newsize, char c = '\0');
		void reserve(size_t newcapacity);
		
		bool operator<(const mystring& s);
		bool operator<=(const mystring& s);
		bool operator>(const mystring& s);
		bool operator>=(const mystring& s);
		bool operator==(const mystring& s);
		bool operator!=(const mystring& s);

		size_t find(char c, size_t pos = 0) const;
		size_t find(const char* s, size_t pos = 0) const;

		mystring& insert(size_t pos, char c);
		mystring& insert(size_t pos, const char* str);
		mystring& erase(size_t pos, size_t len);

	private:
		char* _str;
		size_t _size;
		size_t _capacity;
	};
}


mystring.cpp:

#define _CRT_SECURE_NO_WARNINGS 1

#include "mystring.h"
wzh::mystring::mystring(const char* str) //缺省函数声明处写,定义不需要写
{
	_size = strlen(str);
	_capacity = _size;
	_str = new char[_capacity + 1];
	strcpy(_str, str);
}

wzh::mystring::mystring(const mystring& s)
	:_size(0)
	,_capacity(0)
	,_str(nullptr)
{
	mystring tmp(s._str);
	swap(tmp);
}

void wzh::mystring::swap(mystring& s)
{
	std::swap(_str, s._str);
	std::swap(_size, s._size);
	std::swap(_capacity, s._capacity);
}

wzh::mystring::~mystring()
{
	if (_str)
	{
		delete[] _str;
		_str = nullptr;
	}
	_size = _capacity = 0;
}

wzh::mystring& wzh::mystring::operator=(mystring& s)
{
	swap(s);
	return *this;
}

wzh::mystring::iterator wzh::mystring::begin()
{
	return _str;
}

wzh::mystring::iterator wzh::mystring::end()
{
	return _str + _size;
}

void wzh::mystring::resize(size_t newsize, char c)
{
	if (newsize > _size)
	{
		if (newsize > _capacity)
		{
			reserve(newsize);
		}
		memset(_str + _size, c, newsize - _size);
	}
	_size = newsize;
	_str[newsize] = '\0';
}

void wzh::mystring::reserve(size_t newcapacity)
{
	if (newcapacity > _capacity)
	{
		char* str = new char[newcapacity + 1];
		strcpy(str, _str);
		delete[] _str;
		_str = str;
		_capacity = newcapacity;
	}
}

void wzh::mystring::push_back(char c)
{
	if (_size == _capacity) reserve(_capacity * 2);
	_str[_size++] = c;
	_str[_size] = '\0';
}

wzh::mystring& wzh::mystring::operator+=(char c)
{
	push_back(c);
	return *this;
}

wzh::mystring& wzh::mystring::operator+=(const char* str)
{
	append(str);
	return *this;
}


bool wzh::mystring::empty() const
{
	return _size == 0;
}

size_t wzh::mystring::capacity() const
{
	return _capacity;
}

size_t wzh::mystring::size() const
{
	return _size;
}

char& wzh::mystring::operator[](size_t index)
{
	assert(index < _size);
	return _str[index];
}

const char& wzh::mystring::operator[](size_t index) const
{
	assert(index < _size);
	return _str[index];
}


void wzh::mystring::append(const char* str)
{
	for (int i = 0; i < strlen(str); i++)
		push_back(str[i]);
}

void wzh::mystring::clear()
{
	_size = 0;
	_str[_size] = '\0';
}

bool wzh::mystring::operator<(const mystring& s)
{
	if (_size < s.size()) return true;
	if (_size > s.size()) return false;
	for (int i = 0; i < _size; i++)
	{
		if (_str[i] > s[i]) return false;
		if (_str[i] < s[i]) return true;
	}
	return false;
}

bool wzh::mystring::operator==(const mystring& s)
{
	if (_size != s.size()) return false;
	for (int i = 0; i < _size; i++)
	{
		if (_str[i] != s[i]) return false;
	}
	return true;
}


bool wzh::mystring::operator<=(const mystring& s)
{
	return *this < s || *this == s;
}

bool wzh::mystring::operator>(const mystring& s)
{
	return !(*this <= s);
}

bool wzh::mystring::operator>=(const mystring& s)
{
	return *this > s || *this == s;
}

bool wzh::mystring::operator!=(const mystring& s)
{
	return !(*this == s);
}

ostream& wzh::operator<<(ostream& _cout, const wzh::mystring& s)
{
	for (int i = 0; i < s.size(); i++)
		_cout << s[i];
	return _cout;
}


size_t wzh::mystring::find(char c, size_t pos) const
{
	assert(pos >= 0 && pos < _size);
	for (int i = pos; i < _size; i++)
	{
		if (_str[i] == c) return i;
	}
	return -1;
}

size_t wzh::mystring::find(const char* s, size_t pos) const
{
	assert(pos >= 0 && pos < _size);
	int tmp = 0, ti = 0;
	for (int i = pos; i < _size; i++)
	{
		ti = i;
		tmp = 0;
		while (s[tmp] == _str[ti] && tmp < strlen(s) && ti < _size)
		{
			tmp++;
			ti++;
		}
		if (tmp == strlen(s)) return i;
	}
	return -1;
}

wzh::mystring& wzh::mystring::insert(size_t pos, char c)
{
	assert(pos >= 0 && pos < _size);
	if (_size >= _capacity) reserve(_capacity * 2);
	memmove(_str + pos + 1, _str + pos, sizeof(char));
	_str[pos] = c;
	_size++;
	return *this;
}

wzh::mystring& wzh::mystring::insert(size_t pos, const char* str)
{
	assert(pos >= 0 && pos < _size);
	if (_capacity - _size < strlen(str)) reserve(_capacity + strlen(str));
	memcpy(_str + pos + strlen(str), _str + pos, sizeof(char) * (_size - pos));
	memcpy(_str + pos, str, sizeof(char) * strlen(str));
	/*for (int i = 0; i < strlen(str); i++)
		_str[pos++] = str[i];*/
	_size += strlen(str);
	return *this;
}

wzh::mystring& wzh::mystring::erase(size_t pos, size_t len)
{
	assert(pos >= 0 && pos < _size);
	if (pos + len < _size)
	{
		memcpy(_str + pos, _str + pos + len, sizeof(char) * (_size - pos - len));
		_size -= len;
	}
	else
	{
		_str[pos] = '\0';
		_size = pos;
	}
	return *this;
}

test.cpp:

#define _CRT_SECURE_NO_WARNINGS 1

#include "mystring.h"
//using namespace wzh;
int main()
{
	wzh::mystring s1("apple");
	wzh::mystring s2(s1);
	wzh::mystring s3;
	wzh::mystring::iterator it = s1.begin();

	while (it != s1.end())
	{
		cout << *it++ << ' ';
	}
	cout << endl;
	s1.push_back('x');
	cout << s1 << endl;
	s1.append("bear");
	cout << s1 << endl;
	s1 += "KKK";
	cout << s1 << endl;
	for (auto e : s1)
	{
		cout << e << ' ';
	}
	cout << endl;
	cout << s1.insert(0, 'p') << endl;
	cout << s1.insert(3, "TTT") << endl;
	cout << s1.erase(0, 1) << endl;
	cout << s1.erase(2, 1) << endl;
	cout << s1.insert(0, "YYY") << endl;
	return 0;
}

🍉总结

本篇博客对c++的string类和string类的一些接口进行了介绍,并且对string类的一些接口也进行模拟实现,string类的接口繁多且冗余,我们只需要将一些常用的接口记住就行,在遇到不会的或者记得模糊的接口我们可以去查看文档,cplusplus网页文档放在了文章的开篇处,供大家查询。大家如果觉得有帮助的话,就点个赞呗!
在这里插入图片描述

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

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

相关文章

基于springboot的4S店车辆管理系统(源码等)

摘 要 随着信息技术和网络技术的飞速发展&#xff0c;人类已进入全新信息化时代&#xff0c;传统管理技术已无法高效&#xff0c;便捷地管理信息。为了迎合时代需求&#xff0c;优化管理效率&#xff0c;各种各样的管理系统应运而生&#xff0c;各行各业相继进入信息管理时代&…

【面试系列】详细拆解Java、Spring、Dubbo三者SPI机制的原理

什么是SPI SPI全称为Service Provider Interface&#xff0c;是一种动态替换发现的机制&#xff0c;一种解耦非常优秀的思想&#xff0c;SPI可以很灵活的让接口和实现分离&#xff0c;让api提供者只提供接口&#xff0c;第三方来实现&#xff0c;然后可以使用配置文件的方式来…

面向开发人员的 ChatGPT 提示语教程 - ChatGPT Prompt Engineering for Developers

面向开发人员的 ChatGPT 提示语教程 - ChatGPT Prompt Engineering for Developers 1. 指南1-1. 提示的准则1-2. 配置1-3. 提示语原则原则 1: 写出清晰而具体的指示(原文: Write clear and specific instructions)技巧 1: 使用分隔符来清楚地表明输入的不同部分(原文: Use deli…

2022年NOC大赛编程马拉松赛道初赛图形化高年级A卷-正式卷,包含答案

目录 选择题: 下载打印文档做题: 2022NOC-图形化初赛高年级A卷正式卷 选择题: 1、答案:B 俄罗斯方块是一款风靡全球的益智小游戏,玩家通过移动、旋转和摆放不同造型的方块,使其排列成完整的一行或多行。请问如何旋转图中的蓝色方块,可以使它刚好放入虚线框中,消灭方块…

设计模式——责任链模式

是什么? 场景案例&#xff1a;假设我们现在在公司里面需要请假&#xff0c;那么如果请假的天数比较少&#xff0c;可以直接找组长请假&#xff0c;但是如果是一个星期这种假的话就还需要去找部门主管&#xff0c;如果是半个月以上的假的话就还需要去找副总经理甚至总经理请假…

win10安装Anaconda巨详细[更新于2023.5.7]

目录 一、Anaconda下载&#xff08;官网和清华源,更推荐清华源&#xff09; 1.1、Anaconda官网首页地址 1.2、清华源Anaconda地址 二、Anaconda安装 三、测试Anaconda是否安装配置成功 一、Anaconda下载&#xff08;官网和清华源,更推荐清华源&#xff09; 1.1、Anaconda…

烽火HG680-J_Hi3798MV100_内有普通版和高安版-当贝桌面-卡刷强刷固件包

烽火HG680-J_Hi3798MV100_内有普通版和高安版-当贝桌面-卡刷强刷固件包-内有短接图和教程 特点&#xff1a; 1、适用于对应型号的电视盒子刷机&#xff1b; 2、开放原厂固件屏蔽的市场安装和u盘安装apk&#xff1b; 3、修改dns&#xff0c;三网通用&#xff1b; 4、大量精…

树【二叉树】与森林的相互转化与遍历

一、树与森林的相互转换 预备知识&#xff1a;孩子兄弟表示法。 代码编写出来&#xff1a; typedef struct CSNode{int data;struct CSNode *firstchild,*nextS; }CSNode; 解释&#xff1a;该结点的链域分别指向它的第一个孩子和它同级的兄弟。 &#xff08;一&#xff09;森…

【场景方案】我所遇到的有关前端文件上传的知识点归纳,欢迎大家来补充

文章目录 前言前后端传输的文件格式主要有哪些base64formData 前端上传方案input标签获取文件HTML5的API 切片上传大文件blob数据转成base64未来不间断补充 前言 本文章总结了本人在网上和实际公司项目中遇到的有关前端文件上传功能的知识点&#xff0c;如有更好的方案或者发现…

【Windows】【Audio】Windows 11 声音配置

目录 一. 问题 二. 步骤 三. 配置 3.1 候选列表 3.2 程序事件 3.2.1 Windows 3.2.2 文件资源管理器 3.2.3 Windows 语音识别 一. 问题 印象中记得 Windows XP 启动和关机&#xff0c;还有平常点击的过程中有声音来着&#xff0c;Windows 11 咋没有&#xff1f; 折腾了折…

智能优化算法:浣熊优化算法-附代码

智能优化算法&#xff1a;浣熊优化算法 文章目录 智能优化算法&#xff1a;浣熊优化算法1.浣熊优化算法1.1 初始化1.2 阶段一&#xff1a;狩猎和攻击&#xff08;探索阶段&#xff09; 2.实验结果3.参考文献4. Matlab 摘要&#xff1a;浣熊优化算法&#xff08;Coati Optimizat…

Mysql的可重复读解决了幻读问题吗

针对快照读&#xff08;普通 select 语句&#xff09;&#xff0c;是通过 MVCC 方式解决了幻读&#xff0c;因为可重复读隔离级别下&#xff0c;事务执行过程中看到的数据&#xff0c;一直跟这个事务启动时看到的数据是一致的&#xff0c;即使中途有其他事务插入了一条数据&…

开关电源基础02:基本开关电源拓扑(3)-拓扑分析

说在开头&#xff1a;关于薛定谔的波动方程&#xff08;1&#xff09; 当年毛头小子海森堡在哥廷根求学的时候&#xff0c;埃尔文.薛定谔已经是瑞士苏黎世大学的著名教授了。跟其他那些小天才&#xff08;定位精度&#xff1a;25岁5岁&#xff09;相比&#xff0c;薛定谔只能用…

使用 Python 查找本月的最后一天

文章目录 使用 Python 中的日历库查找月份的最后一天使用 Python 中的 DateTime 模块查找该月的最后一天从每个月的第一天减去一天以找到该月的最后一天使用存储在数组中的预加载日期使用 for 循环查找该月的最后一天打印日历年所有月份的最后一天以查找该月的最后一天 使用 Ar…

Kafka生产者原理

消息发送流程介绍 Producer创建时&#xff0c;会创建⼀个sender线程并设置为守护线程。⽣产消息时&#xff0c;内部其实是异步的&#xff1b;⽣产的消息先经过拦截器->序列化器->分区器&#xff0c;然后将消息缓存在缓冲区&#xff08;该缓冲区也是在Producer创建时创建…

关于clash退出后,华硕电脑连不上网了

关于clash退出后&#xff0c;华硕电脑连不上网了 问题记录 问题记录 昨天因为overleaf老断网&#xff0c;然后我就挂了一下clash&#xff08;第一次用&#xff0c;不怎么懂&#xff09;&#xff0c;后来直接关闭退出了。 今天早上突然浏览器的网页&#xff08;微软自带、华硕…

挑战14天学完Python----初识Python语法

往期文章 Java继承与组合 你知道为什么会划分数据类型吗?—JAVA数据类型与变量 10 &#xff1e; 20 && 10 / 0 0等于串联小灯泡?—JAVA运算符 你真的知道怎样用java敲出Hello World吗&#xff1f;—初识JAVA 目录 往期文章前言1.温度转换实例2. 程序格式框架2.1 高…

ATT汇编快速学习

说明 文档来源 https://flint.cs.yale.edu/cs421/papers/x86-asm/asm.html 使用AT&T语法; 原文档是intel语法翻译过来的; 内容 基于32位, x86的硬件环境; 指令仅仅介绍常用, 即还有很大一部分的指令并没有支持; 编译器(汇编器) GAS(GNU assembler: 即gnu组织提供; 使…

《斯坦福数据挖掘教程·第三版》读书笔记(英文版)Chapter 5 Link Analysis

来源&#xff1a;《斯坦福数据挖掘教程第三版》对应的公开英文书和PPT Chapter 5 Link Analysis Terms: words or other strings of characters other than white space. An inverted index is a data structure that makes it easy, given a term, to find (pointers to) a…