![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Ftgn_dpA
这个作者很懒,什么都没留下…
展开
-
蓝桥杯 长度统计 线段覆盖长度问题
问题描述 给出n个线段以及它们的左端点和右端点。我们要求得到这些线段覆盖部分的长度。如线段[1,2]和[2,3]覆盖了数轴上1到3这个部分,所以它们覆盖的长度就是2。输入格式 第一行一个数n表示有n条线段,之后的n行每行两个整数表示每个线段的左端点和右端点。输出格式 一个数表示覆盖部分的长度。样例输入31 22 34 5样例输出3数据规模和约定 0<n<=1000, 答案不超过32位整数。看到这个问题我首先想到的是集合的并集来计算原创 2022-03-30 23:17:49 · 610 阅读 · 0 评论 -
C++显示杨辉三角
利用循环队列的数据结构://"CirQueue.h"#include<iostream>using namespace std;template<class T>class CirQueue{ private: T *base; int front; int rear; int queuesize; public: CirQueue(int m); ~CirQueue(); void EnQueue(T x); T DeQueu原创 2020-12-13 01:40:01 · 163 阅读 · 0 评论 -
C++串逆置问题
#include<iostream>#include<string>#include<stack>using namespace std;//方法一:利用入栈出栈void StringReverse_1(string &str){ std::stack<char> sta; for (int i = 0; i < str.length(); i++) sta.push(str[i]); for (int j = 0; .原创 2020-12-13 01:25:57 · 356 阅读 · 0 评论 -
利用链表结构实现集合交运算
题目:利用链表数据结构计算集合A和集合B的交要求:数据元素为字符型,不开辟新的存储空间,即计算使用的链表头文件“LinkList.h”:#include<iostream>using namespace std;template<class T>struct Node{ T data; Node *next;};template<class T>class LinkList{private: Node<T> *Hea原创 2020-12-02 10:27:35 · 674 阅读 · 0 评论