C++
文章平均质量分 51
两面包+芝士
主研多模态方向,包括对齐,融合,情感分析,命名实体识别,关系抽取,目标检测,图像描述等
展开
-
加权二叉树的实现与单元测试(python)
加权二叉树,每个节点存储权值(非负整数)。我们定义节点的inbalance作为它的左右子树的和权值的绝对差。一个空子树的权值为0。我们的实现应该支持以下操作:•更新节点权值。•插入新节点。•移动根节点的子树。•找到最不平衡的节点,即最不平衡的节点。因此需要维护一个树,其中树中的每个节点都持有一个权重值作为它的key“inbalance”的value等同于此节点左右子树的求和权值之差。Example:Tree:A(5)/ C(2) D(8)/B(10)原创 2022-04-03 20:48:39 · 540 阅读 · 0 评论 -
C++ 数据结构,vector与栈介绍
0原创 2021-12-27 05:45:00 · 259 阅读 · 0 评论 -
C++ vector和stack入门习题(采用排序)
编写一个 C++ 程序,将正实数读入一个向量(以随机顺序)。 用一个尾随值 -1。 将数字按升序排序并显示排序后的数字。您的程序必须包括以下两个功能:void sort(vector<float> & v);void display(vector<float> & v);Solution to Q1:#include <iostream>#include <vector>using namespace std;vector.原创 2021-12-24 04:00:00 · 643 阅读 · 0 评论 -
C++ Linked lists detail
原创 2021-12-22 03:00:00 · 176 阅读 · 0 评论 -
C++ 链表入门习题
在注释中找到程序 2(在列表的 FRONT 插入几个节点)。修改程序在列表的前面仅插入三 (3) 个节点。测试程序。Q1的解决方案:类和功能都保持不变。这是使用函数的主要原因之一,也就是说,我们可以更改一个函数(或主函数),而保持其他一切不变。将主要更改为:int main() { // insert at the FRONT of the list Node *temp; int number, i; listpointer = NULL; for (i = 0; i < 3;.原创 2021-12-21 05:45:00 · 595 阅读 · 0 评论 -
C++ - 命名空间,argc和argv详解,游戏人生介绍
原创 2021-12-20 15:47:00 · 114 阅读 · 0 评论 -
时间复杂度,贪心算法解最大团问题,回溯算法解0-1背包问题(仅步骤)
一:算法时间复杂性1.写出下列非递归程序的时间复杂性(1)for(i=2;i<=n;++i) for(j=2;j<=i-1;++j) { ++x; a[i,j]=x; }上述程序的时间复杂性为:O(n^2)(2)int i,j x=0;for (i=1;i<n;++i){for (j=i+1;j<=n;++j){++x}}上述程序的时间复杂性为: O(n^2)(3)int i=1;while(i<=n)i=i*2;上原创 2021-12-12 21:42:20 · 3409 阅读 · 0 评论 -
Smart Pointers(智能指针)与Epoch-Based Reclamation (EBR)详细介绍和对比
Smart Pointers它基于三个概念,包括堆栈分配的指向堆分配内存的指针,扮演每个对象的垃圾收集角色和 RAII。有 3 个 API:unique_ptr、shared_ptr 和 weak_ptr。1)unique_ptr 只允许底层指针的一个所有者,但不支持复制,但支持移动语义。 然后,当所有者指针超出范围时,它的内存被回收。因此,它不需要显式调用“删除”。 更重要的是,unique_ptr 可以自我记录并捕获编程错误。尽管如此,它通常需要复制指针。unique_ptr只允许底层指原创 2021-12-14 22:00:00 · 540 阅读 · 0 评论 -
使用Epoch-Based Reclamation(EBR,特定域回收的一种方法)修改 lazy-list
如前文所说,lazy-list最大的隐患莫过于逻辑删除,而没有物理删除问题,因此EBR首先就把这个问题给他solve了。一.EBR修改部分int parse_delete(intset_l_t *set, val_t val) { node_l_t *pred, *curr; int result, validated, isVal; while(1) { //Init pred = set->head; curr = get原创 2021-12-11 14:45:00 · 671 阅读 · 0 评论 -
lazy-list C 代码详解
先从github上可以把相应的Synchrobench代码下载下来https://github.com/gramoli/synchrobench一.lazy-list代码重构的潜在需求: 第一个也是最明显的问题是内存回收问题。 比如在并发执行的过程中,如果只是一个节点b的逻辑移除,即使它不再存在于抽象集合中。 但实际上还是有联系的,只是一开始就达不到。 如下所示这样,如果项目不是空闲的,随着时间的推移,它会导致内存激增。 因此分配给项目节点的内存被回收。如果你让我去做,我会在最后收回记忆来坚持记忆原创 2021-12-10 07:30:00 · 289 阅读 · 0 评论 -
搭建MPI并行计算环境并计算pi值[windows 和 Ubuntu]
文章目录一. 选在Linux,Ubuntu或者Windows上搭建mpi环境First of allWhat’s more二、VS配置mpi三、计算pi值(1)基础编译环境的构建(2)MPICH安装(3)第一个mpi程序:pi值计算搭建MPI并行计算环境,利用计算pi 的公式,计算pi 值,多线程数量n分别使用100、1000、10000计算结果。以下是具体安装流程和实验结果分析,分析n值对pi精度的影响,并行进程的个数对计算速度的影响。一. 选在Linux,Ubuntu或者Windows上搭建m原创 2021-11-27 15:39:45 · 5727 阅读 · 0 评论 -
C++ ppm图像生成 练习题
4.What colour do you get if the three RGB values are the same? E.g. 150, 150, 150. Leave out thesmall numbers because we know that 0, 0, 0 is black. And leave out the large numbers becausewe know that 255, 255, 255 is white. Look somewhere in between. No原创 2021-12-04 05:45:00 · 386 阅读 · 0 评论 -
C++ 递归回溯搜索习题
1.Run the program in the notes that uses the recursive factorial function. Enter the number 24.Explain what happens.Solution to Q1:Factorials get very big. If the number goes past the maximum integer (maxint) that you can store in a computer, then a 1原创 2021-11-24 21:45:00 · 251 阅读 · 0 评论 -
C++ 类,对象和指针入门题
1.Create a class to store the data for an item in a shop. The class must contain the following data:name (string), price (float), number in stock (integer)The class must have a method to load the data and a method to display the data.Declare an array of原创 2021-11-20 09:45:00 · 314 阅读 · 0 评论 -
C++ 引用指针练习
Write a C++ program that displays the address of a float variable. Display the address first in hexadecimal and then in decimal.Solution to Q1:#include <iostream>using namespace std;float f;float *fp;int main() { f = 3.1415; fp = &f; c.原创 2021-11-18 07:45:00 · 244 阅读 · 0 评论 -
C++ 从入门到入土(English Version)Section 9 : Computer Graphics and Command Prompt
原创 2021-11-28 00:15:00 · 69 阅读 · 0 评论 -
C++ 从入门到入土(English Version)Section 8 : Recursion, Searching and Backtracking
原创 2021-11-22 16:15:00 · 59 阅读 · 0 评论 -
C++ 从入门到入土(English Version)Section 7 : Classes, Objects and Pointers
原创 2021-11-19 05:00:00 · 126 阅读 · 0 评论 -
C++ 从入门到入土(English Version)Section 6: Pointers and Call by Reference
原创 2021-11-17 19:45:00 · 334 阅读 · 0 评论 -
C++程序设计(二:机器模拟)
任务 2编写一个模拟 MASSEY 机器的 C++ 程序。程序必须接收表单中的输入由 MASSEY 机器代码指令组成的文本文件。然后你的程序模拟机器运行,即它通过机器代码指令(以正确的顺序)改变根据需要设置寄存器和内存位置的值。您必须设计适当的输出以帮助机器代码程序员查看机器代码指令发生了什么。你应该显示项目,例如程序计数器、指令寄存器、最近更改的寄存器的值,以及最近更改的内存位置的值。确保您通读以下所有部分。Section A - input程序的输入是一个包含 MASSEY 机器代码程序的文本文件原创 2021-11-16 08:30:00 · 1868 阅读 · 0 评论 -
C++程序设计(三:可视化)
任务 3 ( Section9 to Section11)一家生产纽扣的工厂与您签订了合同。 重要的是工厂标识损坏的按钮,以便它们不会提供给商店。 工厂有一台照相机按钮的照片。 相机只能黑白(无彩色),分辨率不是很高很好,但这不是问题。您的工作是编写一个 C++ 程序来识别照片中任何损坏的按钮。 你需要生成一个图像,在每个按钮周围显示一个框。 如果按钮损坏,您必须显示一个红色框,如果按钮没有损坏,您必须显示一个绿色框。 请务必仔细阅读通过以下所有部分。PS:Buttons.ppm and Ass3-s原创 2021-11-19 12:30:00 · 2625 阅读 · 0 评论 -
C++ 实数和二进制操作入门
原创 2021-11-12 10:37:35 · 198 阅读 · 0 评论 -
C++ 从入门到入土(English Version)Section5: Real numbers + bitwise operations
原创 2021-11-08 22:14:47 · 66 阅读 · 0 评论 -
C++ machine code与随机数 进阶习题
原创 2021-11-06 12:04:30 · 58 阅读 · 0 评论 -
C++ 从入门到入土(English Version)Section4: Random numbers + machine code
原创 2021-11-06 12:04:15 · 68 阅读 · 1 评论 -
C++练习题(三)
原创 2021-11-05 17:06:12 · 336 阅读 · 0 评论 -
C++ 从入门到入土(English Version)Section3: Real numbers + bitwise operations
In this section we look at the design of the circuits required to carry out arithmetic in a computer. We also look at how real numbers are stored. Then we get back to C++ programming with bitwiseoperations.原创 2021-11-05 17:06:00 · 67 阅读 · 0 评论 -
C++程序设计一(进制转换)
文章目录作业 1( Section2 to Section5)Notes:Answer:作业 1( Section2 to Section5)编写一个 C++ 程序,将二进制数转换为十进制数 并将十进制数转换为二进制数。 该程序会提示用户输入一个数字。 您必须将数字作为字符串读取。 如果数字是二进制数,则将其转换为十进制数。 如果数字是十进制,则将其转换为二进制。 如果数字无效,则必须显示相应的错误消息。使用下面的示例来(a) 查看需要什么以及(b) 查看可能发生的输出类型Notes:1.十进原创 2021-11-05 16:54:28 · 483 阅读 · 0 评论 -
C++ 练习题(二)计算机存储和数字系统介绍
原创 2021-11-05 11:42:06 · 365 阅读 · 0 评论 -
C++ 从入门到入土(English Version) Section 2:Computer Memory and Number Systems
Section 2:Computer Memory and Number Systems文章目录Section 2:Computer Memory and Number SystemsThe flipflopNumber SystemsThe Decimal number systemThe Binary number systemCarry 1 in binaryBits and BytesAn interesting thoughtConverting binary to decimalConvert原创 2021-11-01 21:45:46 · 497 阅读 · 0 评论 -
C++ 练习题(一:布尔表达式与真值表图文详解)
在每种情况下,给定一个真值表,找出一个等价的布尔表达式,然后画出相关的逻辑电路。Solutions:d) 如果真值表的输出全是 1(或全是 T)?如果真值表的输出都是 0(或全是 F)?给定下面的逻辑电路,找出相关的真值表和布尔表达式:Solutions:最终真值表(如果您愿意,可以使用 T 和 F):这个真值表的布尔表达式是:但实际上该电路为我们提供了一个更简单(和等效)的布尔表达式:3.给定以下布尔表达式,绘制电路并设置真值表:Solutions:使用 A、原创 2021-10-28 21:21:03 · 2409 阅读 · 0 评论 -
C++ 从入门到入土(English Version) Section 1:Gates, Circuits and Boolean Algebra
Section 1 : Gates, Circuits and Boolean Algebra文章目录Section 1 : Gates, Circuits and Boolean AlgebraGatesLogic circuitsBoolean AlgebraReducing Boolean ExpressionsAxioms In Computer Science (the study of what is possible with computers), it is important to原创 2021-10-28 20:43:35 · 1075 阅读 · 0 评论