A1022 Digital Library (30) map的常见用法

【异常】OpenClaw 项目 `fetch failed` 报错问题排查与解决方案Response interrupted: TypeError: fetch failed 针对无超时控制、异常兜底缺失导致的请求中断,封装标准化的安全请求工具,一次性解决超时控制、异常捕获、日志埋点三大问题,全项目替换原生。:将项目运行的 Node.js 版本升级至 18.x 及以上 LTS 版本,使用 Node.js 内置的稳定版。实现的网络请求环节,包括但不限于:第三方开放接口调用、内部服务接口通信、跨域资源请求、外部配置拉取等场景。:针对无法升级 Node.js 版本的存量环境,通过社区稳定兼容包替换原生。类型异常,直接造成业务请求响应中断。第二步:业务代码改造,替换原生。 阅读详情

注意同一行有很多的keyword所以输入要判断是否到达了最后一个输入,也即是否到达了换行符的位置;

while(1)
	    {
	       cin>>keyword;
	       mp[keyword].insert(temp);
	       char c=getchar();
	       if(c=='\n')
	       break;  
		}

本题在最后的输出过程应使用*it语句,实际上这里已经转换成了解决set的输出问题。

#include<iostream>
#include<map>
#include<set>
#include<cstdio>
#include<string>
using namespace std;
map<string , set<int>> mp;
int main()
{
	int n,m,temp,k;
	string title,author,keyword, publisher,year,str;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		scanf("%d",&temp);
		getchar();
		getline(cin,title);
		getline(cin,author);
	    while(1)
	    {
	       cin>>keyword;
	       mp[keyword].insert(temp);
	       char c=getchar();
	       if(c=='\n')
	       break;  
		}
		getline(cin,publisher);
		getline(cin,year);	
		mp[title].insert(temp);
		mp[author].insert(temp);
		mp[publisher].insert(temp);
		mp[year].insert(temp);
	}
	cin>>m;
	for (int i=1;i<=m;i++)
	{
		scanf("%d: ",&k);
		getline(cin,str);
		printf("%d: ",k);
		cout<<str<<endl;
		if(mp.find(str)==mp.end())
		printf("Not Found\n");
		else
		{
		  for(auto it=mp[str].begin();it!=mp[str].end();it++)
		  {
			printf("%07d\n",*it);
	      }
		}
			
	}
}
【网络基础2】路由器的 “两扇门”:二层接口和三层接口到底有啥不一样? 家里的路由器背后总有几个网线接口,有的标着 “LAN”,有的标着 “WAN”;公司机房的路由器上,接口更是五花八门,有的插着网线,有的连着光纤,旁边还贴着 “GE0/0/1”“Eth-Trunk1” 这样的标签。你可能会想:不就是插网线的地方吗?有啥区别?其实,这些接口分 “二层接口” 和 “三层接口”,它们的作用差得远了 —— 就像你家的门,有的是 “小区内的单元门”(只通小区内部),有的是 “小区的大门”(能通往外面的世界)。接下来,咱们用大白话 + 生活例子,一点点把这两种接口讲透。 阅读详情

相关推荐

永不消逝的电波 -GSM空口信号的接收与解码

一开始接触软件无线电应该是从很早之前对RFID洗衣卡的解密开始的,后来接触人员定位,慢慢的打开了这样一扇大门。。。。 翻到之前做的GSM信号的接收解码,今天就对其过程做一个记录,也不是什么新颖的内容,权当是记录和回忆了。 对于GSM网络的相关内容,不是非常的熟悉,如有不正确的,欢迎批评指正。

Jack.Xu 专栏 1万+

PAT习题解:1022. Digital Library (30)

题目链接:http://www.patest.cn/contests/pat-a-practise/1022 这道题目我没想到什么好办法做,最后参考了闲云阁的文章,用map 和 set 做出来,算是顺便学习了一下 STL 里面 map 和 set 的用法。话说C++的输入输出真是麻烦啊,这题用Python做的话写起来会很简单吧。 #define _CRT_SECURE_NO_WARNING

by21010的专栏 760

如何利用URDF文件表示并联结构(仅适用于支持SDF格式的仿真环境)

介绍了一种使用URDF文件在Gazebo中表示并联结构的方法,该方法使用了URDF的SDF拓展。在一个具有并联结构的双足机器人上应用并演示了此方法的有效性。

RobotFreak的博客 3851

PAT甲级 1022 Digital Library

PAT甲级 1022 Digital Library A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned...

旺崽的博客 2936

5G移动网络运维(优化)

5G 网络优化现状 移动通信行业属于技术密集型行业,是国民经济的重要支柱以及整个社会经济运转体系中不可或缺的基础。2019 年年底 5G 开始商用,截止到 2020 年3月,我国三大运营商建设了 16.1 万个 5G 基站,我国成为目前全球 5G 基站最多的国家。预计到 2020 年年底,我国运营商会建设大概 70 万个 5G 基站。基于 5G高频段的特性,信号覆盖距离会低于ins 基站,再加上 5G 万物互联的巨大经济潜力价值需求,后续三大运营商在 5G 基站建设数量上势必会超过当前 LTE 基站数量的

2301_78171382的博客 1325

伺服驱动器485通信

485通信使用方法,485通信在上位机和伺服驱动器之间的应用,根据需要驱动电机旋转。

haipi511715316的博客 1万+

1022. Digital Library (30)

原题地址:http://www.patest.cn/contests/pat-a-practise/1022A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published ye

dyeDeny的流水账 542

Airtest进阶使用篇-提高脚本稳定性+批量运行脚本

Airtest进阶篇,主要分享如何提高脚本稳定性+如何批量运行脚本生成测试报告!

程序员小杨哥的博客 2569

【PAT】A1022 Digital Library【Map的使用】

A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number a...

elegant coder 1049

如何离线环境下安装Dify插件 (可提供远程指导协助)

离线环境下安装Dify插件

litlit023的专栏 8101

YOLO11涨点优化:小目标检测 | 多头检测器提升小目标检测精度

引入多头检测器助力YOLO11,添加一个微小物体的检测头暴力提升小目标检测性能

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 4742

1022 Digital Library (30 分)

1022 Digital Library (30 分) A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigne...

92377 884

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

[PAT A1022]Digital Library

[PAT A1022]Digital Library 题目描述 A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is a...

欢迎来到我的编程小屋 591

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

PAT甲级 1022 Digital Library (30分)

1022 Digital Library (30分) 题目链接:PAT A 1022 题目大意:有一数字图书馆,对于每一本书给出如下信息:书的id,书的名字,书的作者,书的关键字,书的出版社以及书的出版年份。要求根据输入的查找信息输出相应书的ID(7位数字)。 思路分析:这道题题意很直观,但是需要用到的知识点比较多。首先根据题目要求可以分析出这道题一定是使用STL中的map去解决,而且由于题...

weixin_43684054的博客 217

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

PAT 甲级 1022(Digital Library)

PAT 甲级 1022题目要求翻译代码思路 题目要求 A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any query fro

qq_42865772的博客 306

1022 Digital Library (30)

1022 Digital Library (30) A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned...

chenyutingdaima的博客 179

1022 Digital Library (30)(30 分)

1022 Digital Library (30)(30 分) A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is as...

Become hunger become strong 853

1022 Digital Library (30)(30 分)

1 题目 2 解题思路 3 AC代码 1 题目 A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book ...

大山喵写博客的地方 1251

A1022 Digital Library [map]

思路:根据书本信息查出所有的与之相关的书本编号,用map<string,set> 存 开五个容器存不同信息 根据不同的查询种类 利用关键字查询。 注意事项: 参数传引用比传值更快 #include<vector> #include<iostream> #include<algorithm> #include<unordered_map> #include<set> #include<map> #include<cst.

_计算机好苦 125

PAT A1022 Digital Library

记录一下这题看似复杂但写法简洁的题。 A1022 Digital Library A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given

kkzzjx 199

1022 Digital Library (30分)(map的常见用法)

这类题目是C++标准模板库的使用,是重点知识。 题目描述如下: 题目大致意思: 根据不同的条件去查询书籍的ID。 大致思路: 这道题目的思路很直接,使用暴力的方法应该不会超时,先试试。 提交结果如下: 并未超时,但是有两个测试用例未通过,放在第二轮刷题时去解决。 提交的代码如下: #include<iostream> #include<vector> #include<string> #include<set> using namespace std;

weixin_44046769的博客 146

1022 Digital Library (30 分)

注意: 1.书名是7位数,需要补零。 2.题目要求按照从小到大输出书名,所以用set比较好。 3.关键字的读入技巧要学到。 4.对参数使用引用会稍微快点。 //map的应用 #include&lt;cstdio&gt; #include&lt;iostream&gt; #include&lt;map&gt; #include&lt;set&gt; #include&lt;algorithm&g...

姚军 830

PAT A 1022 Digital Library (30 分)

一、题目概述&样例 略 二、技巧 1、 由于索引没有顺序要求,使用unordered_map可以节省大量运行时间; 2、 一行内读取多个空格分割的字符串 由于cin不读取空格和换行,因此cin后在读取一个字符,根据字符为换行还是空格判断是否结束; while( cin >> str ) { map_book[3][str]...

Siumai's Blog 202

1022 Digital Library 30

[PAT甲级] 1022 Digital Library 30

number404的博客 178

PAT A1022 Digital Library (30分)(非map解法)

1022 Digital Library (30分) A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any query fro

weixin_45964844的博客 238

PAT 1022 Digital Library

原文链接:欢迎大家访问我的个人博客 原题链接   PAT 1022 Digital Library (30分) 考点   数据输入 map 思路   我想大家拿到题目首先想到的方法肯定是用结构体来进行数据的存储,在根据查询的条件进行筛选输出。但是我在这篇博客中获得了新的思路。   使用map<string,set<int> >将每一个查询的条件与其相对应的集合...

我是没有梦想的小白 132
上一篇: A1071 Speech Patterns (25) map的常见用法
下一篇: 优先队列关于重载运算符,解决结构体优先级设置问题的相关代码
coder_Kim
博客等级 码龄8年 2粉丝 160原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值