3.9Code

news2025/9/18 14:45:06

基于顺序存储结构的图书信息表的图书去重 

#include<iostream>
#include<stdlib.h>
#include<string.h>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	char no[50];
	char name[50];
	float price;
}Book;

typedef struct{
	Book* elem;
	int len;
}SqList;

status InitList(SqList* L,int n){
	L->elem=(Book*)malloc((n+5)*sizeof(Book));
	if(!L->elem) exit(-1);
	L->len=0;
	return OK;
}

status CreateList(SqList* L,int n){
	for(int i=0;i<n;i++){
		bool flag=true;
		Book b;
		cin>>b.no>>b.name>>b.price;
		for(int j=0;j<L->len;j++){
			if(!strcmp(b.no,L->elem[j].no)){
				flag=false;
				break;	
			}
		}
		if(flag){
			L->elem[L->len]=b;
			L->len++;
		}
	
	}
	return OK;
}


void PrintList(SqList* L){
	printf("%d\n",L->len);
	for(int i=0;i<L->len;i++){
		printf("%s %s %.2f\n",L->elem[i].no,L->elem[i].name,L->elem[i].price);
	}
}

int main(){
	SqList L;
	int n=0;
	cin>>n; //图书数 
	InitList(&L,n);
	CreateList(&L,n);
	PrintList(&L); 
	return 0;
}



终于开链表了开链表了T_T

基于链式存储结构的图书信息表的创建和输出

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;     //这样typedef,可以在后期比较方便地创建指向链表结点的指针 

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

//创建链表(含头结点),顺便返回链表长度 
int CreateList(LinkList& L){
	string no,name;
	float price;
	LinkList r=L;
	LinkList p;
	int elemCnt=0;
	while(1){
		//后插法创建链表
		cin>>no>>name>>price;
		if(no=="0" && name=="0" && price==0.0)
			break;
		else{
			p=new LNode;
			p->data.no=no;
			p->data.name=name;
			p->data.price=price;
			p->next=NULL;
			r->next=p;
			r=p;
			elemCnt++;
		} 
	} 
	return elemCnt;
}

void PrintList(LinkList& L,int n){
	LinkList p=L->next;
	cout<<n<<endl;
	while(p){
		cout<<fixed<<setprecision(2);
		cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		p=p->next;
	}
	
}

int main(){
	LinkList L;
	int n=0;
	InitList(L);
	n=CreateList(L);
	PrintList(L,n);
	return 0;
} 

知识点

cout<<fixed<<setprecision(2);

需要添加头文件iomanip

这个用于精度控制(不然如果用%.2f,C和C++风格字符串混在一起也太乱糟了)

(顺便,C中其实是没有string的,如果定义了string,再用printf输出的话,要.c_str() )

基于链式存储结构的图书信息表的排序

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

int CreateList(LinkList& L){
	string no,name;
	float price;
	LinkList r,p;
	r=L;
	int len=0;
	while(1){
		cin>>no>>name>>price;
		if(no=="0" && name=="0" && price==0.0)
			break;
		p=new LNode; //不要漏掉! 
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		r->next=p;
		r=p;
		len++;
	}
	return len;
}

//排序 
void SortList(LinkList& L,int n){
	LinkList p;
	for(int i=0;i<n-1;i++){
		p=L->next;
		int j=0;
		while(p && j<n-1-i){
			if(p->data.price<p->next->data.price){
				Book b=p->data;
				p->data=p->next->data;
				p->next->data=b;
			}
			p=p->next;
			j++;
		}
	}
	
} 

void PrintList(LinkList& L){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		p=p->next;
	}
}

int main(){
	LinkList L;
	InitList(L);
	int len=CreateList(L);
	SortList(L,len);
	PrintList(L); 
}

知识点

对于链表的冒泡排序:(在创建链表时顺便就得到了链表长度,不用再额外遍历一遍了)

另:对定义链表的语句理解:

之后写LinkList L,L就是一个LinkList类型的指针,相当于一个指向链表结点的指针,包括在遍历时用到的辅助指针p等,都是这个类型的。

若想往结点里存数据,那么就先要为它开辟空间,所以常有这样的定义语句:

LinkList p;
p=new LNode;

基于链式存储结构的图书信息表的修改 

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

int CreateList(LinkList& L,float &sum){
	string no,name;
	float price;
	LinkList r,p;
	r=L;
	int len=0;
	while(1){
		cin>>no>>name>>price;
		if(no=="0" && name=="0" && price==0.0)
			break;
		p=new LNode; //不要漏掉! 
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		r->next=p;
		r=p;
		len++;
		sum+=price;
	}
	return len;
}

void ModifyList(LinkList& L,float avg){
	LinkList p=L->next;
	while(p){
		if(p->data.price<avg)
			p->data.price*=1.2;
		else
			p->data.price*=1.1;
		p=p->next;
	}
} 

void PrintList(LinkList& L){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		p=p->next;
	}
}

int main(){
	LinkList L;
	InitList(L);
	float sum=0.0;
	int len=CreateList(L,sum);
	float avg=sum/(float)len;
	cout<<fixed<<setprecision(2);
	cout<<avg<<endl;
	ModifyList(L,avg);
	PrintList(L); 
}

基于链式存储结构的图书信息表的逆序存储(链表逆序就用头插法实现即可,很简单)

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

void CreateList(LinkList& L){
	int n;
	cin>>n; //链表长度 
	string no,name;
	float price;
	LinkList r,p;
	int cnt=0;
	while(cnt<n){
		cin>>no>>name>>price;
		p=new LNode; //不要漏掉! 
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		
		//头插法实现逆序存储
		r=L->next;
		L->next=p;
		p->next=r; 
		
		cnt++;
	}
}


void PrintList(LinkList& L){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		p=p->next;
	}
}

int main(){
	LinkList L;
	InitList(L);
	float sum=0.0;
	CreateList(L);
	PrintList(L); 
}

查找最贵图书

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

//返回最高图书价格 
float CreateList(LinkList& L){
	int n;
	cin>>n; //链表长度 
	string no,name;
	float price;
	float max=0.0; 
	LinkList r,p;
	r=L; //等于L比较好,如果等于L->next,之后会出现r=p->next的情况,这时候r的next就不太好了 
	int cnt=0;
	while(cnt<n){
		cin>>no>>name>>price;
		p=new LNode; //不要漏掉! 
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		if(price>max)
			max=price;
		r->next=p;
		r=p;
		
		cnt++;
	}
	return max;
}

//返回最贵图书的数量 
int TraverseList(LinkList&L,float max){
	LinkList p=L->next;
	int cnt=0;
	while(p){
		if(p->data.price==max)
			cnt++; 
		p=p->next;
	}
	return cnt;
}

void PrintList(LinkList& L,float max){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		if(p->data.price==max){
			cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		}
	
		p=p->next;
	}
}

int main(){
	LinkList L;
	InitList(L);
	float max=CreateList(L);
	cout<<TraverseList(L,max)<<endl;
	PrintList(L,max); 
}

查找最爱图书(同顺序表,用一个数组存储待查序列,代码写的比较乱功能封装的也不好,摆烂..)

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

//返回最高图书价格 
void CreateList(LinkList& L){
	int n;
	cin>>n; //链表长度 
	string no,name;
	float price;
	LinkList r,p;
	r=L; //等于L比较好,如果等于L->next,之后会出现r=p->next的情况,这时候r的next就不太好了 
	int cnt=0;
	while(cnt<n){
		cin>>no>>name>>price;
		p=new LNode; //不要漏掉! 
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		r->next=p;
		r=p;
		
		cnt++;
	}
}

//返回最爱图书的数量 
int TraverseList(LinkList&L,string love){
	LinkList p=L->next;
	int cnt=0;
	while(p){
		if(p->data.name==love)
			cnt++; 
		p=p->next;
	}
	return cnt;
}

void PrintList(LinkList& L,string love){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		if(p->data.name==love){
			cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		}
	
		p=p->next;
	}
	
}

int main(){
	LinkList L;
	InitList(L);
	CreateList(L);
	int num;
	cin>>num;
	string love[num];
	for(int j=0;j<num;j++)
		cin>>love[j]; 
	for(int i=0;i<num;i++){
		if(TraverseList(L,love[i])!=0){
			cout<<TraverseList(L,love[i])<<endl;
			PrintList(L,love[i]); 
		}
		else cout<<"Sorry,there is no your favourite!"<<endl;
			
	}
	
}

基于链式存储结构的图书信息表的最佳位置图书的查找

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

int CreateList(LinkList& L){
	int n;
	cin>>n; //链表长度 
	string no,name;
	float price;
	LinkList r,p;
	r=L; //等于L比较好,如果等于L->next,之后会出现r=p->next的情况,这时候r的next就不太好了 
	int cnt=0;
	while(cnt<n){
		cin>>no>>name>>price;
		p=new LNode; //不要漏掉! 
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		r->next=p;
		r=p;
		
		cnt++;
	}
	return n;
}

//返回最爱图书的数量 
int TraverseList(LinkList&L,string love){
	LinkList p=L->next;
	int cnt=0;
	while(p){
		if(p->data.name==love)
			cnt++; 
		p=p->next;
	}
	return cnt;
}

void PrintList(LinkList& L,int place,int n){
	if(place<1||place>=n)cout<<"Sorry,the book on the best position doesn't exist!"<<endl;
	else{
		LinkList p=L->next;
		int index=0;
		while(p){
			cout<<fixed<<setprecision(2);
			if(index==place-1){
				cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
				break;
			}
	
		p=p->next;
		index++;
		}
	}
	
	
}

int main(){
	LinkList L;
	InitList(L);
	int n=CreateList(L);
	int searchNum; //要查找的图书的数目
	cin>>searchNum;
	int place[searchNum];
	for(int i=0;i<searchNum;i++){
		cin>>place[i];
	} 
	for(int i=0;i<searchNum;i++){
		PrintList(L,place[i],n);
	}
	
}

接下来是入库出库(即插入删除)

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;     //这样typedef,可以在后期比较方便地创建指向链表结点的指针 

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

//创建链表(含头结点),顺便返回链表长度 
int CreateList(LinkList& L){
	int elemCnt;
	cin>>elemCnt;
	string no,name;
	float price;
	LinkList r=L;
	LinkList p;

	for(int i=0;i<elemCnt;i++){
		//后插法创建链表
		cin>>no>>name>>price;

		p=new LNode;
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		
		r->next=p;
		r=p;
		 
	} 
	return elemCnt;
}

//插入链表
bool InsertList(LinkList& L,int n,int place,Book b){
	bool flag=true;
	if(place<1 || place>n){
		cout<<"Sorry,the position to be inserted is invalid!"; 
		flag=false;		
	}

	else{
		LinkList p=L; 
		int cnt=0;
		while(cnt<place-1 && p){
			p=p->next; //找到要插入位置的前一个
			cnt++;			
		}
		//已找到位置
		LinkList q=new LNode;
		q->data.no=b.no;
		q->data.name=b.name;
		q->data.price=b.price;
		q->next=NULL;
		
		q->next=p->next;
		p->next=q;
	 
	}
	return flag;
} 

void PrintList(LinkList& L){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		p=p->next;
	}
	
}

int main(){
	LinkList L;
	InitList(L);
	int n=CreateList(L);
	int place;
	cin>>place;
	Book b;
	cin>>b.no>>b.name>>b.price;
	if(InsertList(L,n,place,b))
		PrintList(L);
	return 0;
} 

知识点

当设计插入、删除这些操作时,因为要输出不合法的情况,所以可以为插入删除函数设置一个bool类型的返回值

下面是出库(搞清楚链表怎么插入怎么删除就行很简单)

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;     //这样typedef,可以在后期比较方便地创建指向链表结点的指针 

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

//创建链表(含头结点),顺便返回链表长度 
int CreateList(LinkList& L){
	int elemCnt;
	cin>>elemCnt;
	string no,name;
	float price;
	LinkList r=L;
	LinkList p;

	for(int i=0;i<elemCnt;i++){
		//后插法创建链表
		cin>>no>>name>>price;

		p=new LNode;
		p->data.no=no;
		p->data.name=name;
		p->data.price=price;
		p->next=NULL;
		
		r->next=p;
		r=p;
		 
	} 
	return elemCnt;
}

//删除链表
bool DeleteList(LinkList& L,int n,int place){
	bool flag=true;
	if(place<1 || place>n){
		cout<<"Sorry,the position to be deleted is invalid!"; 
		flag=false;		
	}

	else{
		LinkList p=L; 
		int cnt=0;
		while(cnt<place-1 && p){
			p=p->next; //找到要插入位置的前一个
			cnt++;			
		}
		//已找到位置
		
		LinkList tmp=p->next;
		p->next=tmp->next; 
		free(tmp);
	 
	}
	return flag;
} 

void PrintList(LinkList& L){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		p=p->next;
	}
	
}

int main(){
	LinkList L;
	InitList(L);
	int n=CreateList(L);
	int place;
	cin>>place;
	if(DeleteList(L,n,place))
		PrintList(L);
	return 0;
} 

图书去重

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

typedef int status;

#define OK 1

using namespace std;

typedef struct{
	string no;
	string name;
	float price;
}Book;

typedef struct LNode{
	Book data;
	struct LNode* next;
}LNode,*LinkList;     //这样typedef,可以在后期比较方便地创建指向链表结点的指针 

void InitList(LinkList& L){
	L=new LNode;
	L->next=NULL;
}

//创建链表(含头结点),顺便返回链表长度 
int CreateList(LinkList& L){
	int elemCnt;
	cin>>elemCnt;
	
	int realCnt=elemCnt;
	
	string no,name;
	float price;
	LinkList r=L;
	LinkList p;
	LinkList tmp;

	for(int i=0;i<elemCnt;i++){
		//后插法创建链表
		cin>>no>>name>>price;
		tmp=L->next;
		bool ifInsert=true;
		while(tmp){
			if(tmp->data.no==no){
				cout<<"有重名"<<endl;
				realCnt--;
				ifInsert=false;
			}
			tmp=tmp->next;
		}
		if(ifInsert){
			p=new LNode;
			p->data.no=no;
			p->data.name=name;
			p->data.price=price;
			p->next=NULL;
		
			r->next=p;
			r=p;
			cout<<"成功插入"<<endl;
		}
		
		 
	} 
	return realCnt;
}



void PrintList(LinkList& L){
	LinkList p=L->next;
	while(p){
		cout<<fixed<<setprecision(2);
		cout<<p->data.no<<" "<<p->data.name<<" "<<p->data.price<<endl;
		p=p->next;
	}
	
}

int main(){
	LinkList L;
	InitList(L);
	cout<<CreateList(L)<<endl;
	PrintList(L);
	return 0;
} 

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

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

相关文章

Linux 学习(持续更新。。。)

wc命令 命令直接执行&#xff0c;输出包含四项&#xff0c;分别代表&#xff1a;行数、字数、字节数、文件。 例子:编译下列代码: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #inclu…

七、软考-系统架构设计师笔记-数据库设计基础知识

1、数据库基础概念 数据库基本概念 数据(Data)数据库(Database)数据库管理系统(DBMS)数据库系统(DBS) 1.数据(Data) 是数据库中存储的基本对象&#xff0c;是描述事物的符号记录。 数据的种类&#xff1a; 文本、图形、图像、音频、视频等。 2.数据库(Database, DB) 数据库…

JavaScript代码混淆与防格式化功能详解

在前端开发中&#xff0c;为了增加代码的安全性&#xff0c;防止恶意分析和逆向工程&#xff0c;有时候会采用一些防格式化的技术。这些技术主要通过混淆和难以阅读的方式来防止代码的易读性&#xff0c;提高代码的复杂度&#xff0c;增加攻击者分析的难度。 1. 代码压缩与混淆…

docker 使用官方镜像搭建 PHP 环境

一、所需环境&#xff1a; 1、PHP&#xff1a;7.4.33-fpm 的版本 2、Nginx&#xff1a;1.25.1 的版本 3、MySQL&#xff1a; 5.7 的版本 4、Redis&#xff1a;7.0 的版本 1.1、拉取官方的镜像 docker pull php:7.4.33-fpm docker pull nginx:1.25.1 docker pull mysql:5.7 do…

Character类

Character类 功能&#xff1a;实现了对 基本型数据的类包装。 构造方法&#xff1a; (char c) 常用方法&#xff1a; • public static boolean (char ch)//ch是数字字符返回true。 • public static boolean (char ch)//ch是字母返回 true。 • public static char (char c…

商家转账到零钱申请失败怎么办

商家转账到零钱是什么&#xff1f; 商家转账到零钱是微信商户号里的一个功能&#xff0c;以前叫做企业付款到零钱。从 2022 年 5 月 18 日开始&#xff0c;原企业付款到零钱升级为商家转账到零钱&#xff0c;已开通商户的功能使用不受影响&#xff0c;新开通商户可前往产品中心…

简介:图灵机和图灵测试

一、图灵机&#xff08;Turing machine&#xff09; 图灵机&#xff08;Turing machine&#xff09;是由英国数学家Alan Turing于1936年提出的一种抽象计算模型&#xff0c;阿兰图灵在24岁时发表论文《On Computable Numbers, with an Application to the Entscheidungsproble…

指针总结及例题总结

1 定义 指针是用来存放地址的变量 不同类型的指针变量所占用的存储空间是相同的&#xff0c;sizeof(int)sizeof(char)sizeof(double)... *是解引用操作符&#xff0c;&是取地址操作符&#xff0c;两者有着抵消作用 int a20;int* p&a;*p*&a20; 2&#xff0c;…

windows更改账户名

win R输入netplwiz 点击用户名进去&#xff0c; 修改用户名之后重启即可。

echarts 模拟时间轴播放效果

使用echarts柱状图模拟时间轴播放控制。开始/暂停/快进/慢进/点选 代码可直接放echart官方示例执行 let start new Date(2024-01-01); let end new Date(2024-01-10); let diff end - start; let dotLen 200;let data [start, end]; option {color: [#3398DB],tooltip: …

【笔记】Android ServiceStateTracker 网络状态变化逻辑及SPN更新影响

业务简介 在网络状态变化的时候&#xff08;数据或WiFi&#xff09;&#xff0c;会更新SPN。 基于Android U的代码分析。 分类&#xff1a;SPN Data_Dic-的博客-CSDN博客 功能逻辑 状态说明 飞行模式下注册上WFC的话&#xff0c;注册状态MD上报 regState: NOT_REG_MT_NOT…

Igraph入门指南 4

二、图的创建 图分有向图和无向图&#xff0c;所以图的创建有各自的实现方式。 1、手工创建图&#xff1a; 1-1 通过文本创建&#xff1a;graph_from_literal 通过每项提供两个顶点名&#xff08;或ID号&#xff09;作为一条边的格式&#xff0c;手动创建图&#xff0c;顶点…

RocketMQ-存储与弹性伸缩

存储与弹性伸缩 一、介绍二、存储架构图1.CommitLog2.ConsumeQueue3.IndexFile 三、消息读写流程1.写入流程1.1 获取Topic元数据1.2 消息投递1.3 消息写入 2.读取流程2.1 获取Topic元数据2.2 消息拉取2.3 消息消费 四、消息持久化1.页缓存2.刷盘2.1 同步刷盘2.2 异步刷盘 五、集…

力扣199. 二叉树的右视图(DFS,BFS)

Problem: 199. 二叉树的右视图 文章目录 题目描述思路解题方法复杂度Code 题目描述 思路 无论是DFS还是BFS我们都要思考到达二叉树的每一层&#xff08;或者每一层中的每一个节点&#xff09;时&#xff0c;我们都该如何按题目要求做出对应得处理!!!在本体中我们主要是&#x…

为什么不用 index 做 key?

“在 Vue 中&#xff0c;我们在使用 v-for 渲染列表的时候&#xff0c;为什么要绑定一个 key&#xff1f;能不能用 index 做 key&#xff1f;” 在聊这个问题之前我们还得需要知道 Vue 是如何操作 DOM 结构的。 虚拟DOM 我们知道&#xff0c;Vue 不可以直接操作 DOM 结构&am…

使用docker部署redis集群

编写脚本 批量创建目录文件&#xff0c;编写配置文件 [rootlocalhost ~]# cat redis.sh #/bin/bash for port in $(seq 1 6); do mkdir -p /mydata/redis/node-${port}/conf touch /mydata/redis/node-${port}/conf/redis.conf cat << EOF >>/mydata/redis/node-…

吴恩达deeplearning.ai:倾斜数据集的误差指标精确率、召回率

以下内容有任何不理解可以翻看我之前的博客哦&#xff1a;吴恩达deeplearning.ai专栏 文章目录 倾斜数据集的误差指标罕见病预测精确率和召回率 精确率和召回率的权衡精确率和召回率的矛盾关系 F1算法 倾斜数据集的误差指标 在神经网络中&#xff0c;如果你的数据集中正例和负…

吉林大学 容斥原理 章节作业

作业题填空题解答题 作业题 填空题 聚会上&#xff0c;5位先生各自寄存自己的帽子。在返还时&#xff0c;有( )种方法使得至少有一位先生拿到的是自己原来的帽子。 【答案】76 计算多重集 S { 4 ⋅ a , 3 ⋅ b , 4 ⋅ c , 6 ⋅ d } S\{4 \cdot a, 3 \cdot b, 4 \cdot c, …

黑马点评-附近商户实现

GEO数据结构 Redis在3.2版本中加入了对GEO的支持&#xff0c;允许存储地理坐标信息&#xff0c;根据经纬度来检索数据。 GEO本质上是基于sortedSet实现的&#xff0c;在Sorted Set中&#xff0c;每个成员都是与一个分数(score)相关联的&#xff0c;这个分数用于对成员进行排序…

如何利用生成式人工智能助力短视频剧本创作?

短视频已成为现代人获取娱乐和信息的一种流行方式。不同于传统的电影和电视剧&#xff0c;短视频的时长通常较短&#xff0c;内容形式多样&#xff0c;更适合快节奏的社会生活。本文将讨论如何编写短视频剧本&#xff0c;以及它与传统故事在结构和内容上的区别。 简介 短视频剧…