Trie树

博客贴代码老出错也是醉了。。。

#include<iostream>
using namespace std;
struct node{
	
	struct node*child[26];
	int t;
	bool exist;
	node()
	{
	
		t=0;
		for(int i=0;i<26;i++)
		{
		child[i]=NULL;
		//path[i]='\0';
		}
	}
};
inline void makeTrie(node* head,string a)
{
	if(head)
	{
		
		head->t++;
	if(head->child[a[0]-'a']!=NULL)
		{
			
			
			if(a.length()>1)makeTrie(head->child[a[0]-'a'],a.substr(1));
			else{
				head->child[a[0]-'a']->t++;
			}
		}
		else{
			
			head->child[a[0]-'a']=new node();
			
			
			if(a.length()>1)makeTrie(head->child[a[0]-'a'],a.substr(1));
			else{
				head->child[a[0]-'a']->t++;
			}
		}
	}
	
}
void release(node*root)
{
	
	if(root)
	{
		
		for(int i=0;i<26;i++)
		{
			release(root->child[i]);
			if(root->child[i])delete root->child[i];
		}
		
		
	}
	
	
}
int find(node*head,string str)
{
	
	node*temp=head;
	while(1)
	{
		if(temp==NULL)return 0;
		temp=temp->child[str[0]-'a'];
		if(temp==NULL)return 0;
		if(str.length()<=1) break;
		str=str.substr(1);
		
	}
	if(temp==NULL)return 0;
	return temp->t;
}
int main()
{
	string str="123";
//	cout<<str.substr(1);
	int n,m;
	cin>>n;
	node* root=new node();
	root->t=0;
	while(n--)
	{
	 cin>>str;
	 makeTrie(root,str);
	}	
	
	cin>>m;
	while(m--)
	{
		cin>>str;
		cout<<find(root,str)<<endl;
		
	}
	
}


内容概要:本文详细介绍了华为推出的面向全场景的分布式操作系统HarmonyOS。HarmonyOS旨在打破设备间的壁垒,实现万物互联,通过分布式软总线和分布式任务调度等核心技术,让不同设备协同工作,如手机、平板、智能家居等设备间无缝流转任务。其应用生态涵盖教育、金融、出行等多个领域,华为通过资金、技术支持和流量扶持吸引开发者,推动生态繁荣。HarmonyOS从2019年首次发布至今,经历了多个版本迭代,性能和安全性不断提升,用户体验更加智能便捷。尽管面临应用生态丰富度不足、市场竞争压力等挑战,华为通过优化开发工具、加强市场推广等策略积极应对。未来,HarmonyOS将在分布式技术、AI融合和隐私安全等方面持续创新,并在智能家居、车联网、工业互联网等领域拓展生态。 适合人群:对操作系统技术感兴趣的专业人士、开发者、科技爱好者。 使用场景及目标:①了解HarmonyOS的技术架构和分布式技术的特点;②探讨HarmonyOS在智能家居、车联网等领域的应用前景;③评估HarmonyOS对现有操作系统市场的潜在影响。 阅读建议:HarmonyOS作为一款面向全场景的操作系统,不仅涉及技术实现,还包括生态建设和用户体验。因此,在阅读过程中,应重点关注其技术优势、应用场景及未来发展潜力,结合自身需求思考其在实际生活和工作中的应用价值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值