小编Avi*_*mar的帖子

函数重载和函数指针

函数的名称是指向函数的指针......
但是在函数重载的情况下,两个函数的名称是相同的...
那么名称指向哪个函数?

c++

17
推荐指数
1
解决办法
4894
查看次数

最大化所有可能的子阵列的特定总和

考虑下面这样的数组:

  {1, 5, 3, 5, 4, 1}
Run Code Online (Sandbox Code Playgroud)

当我们选择一个子阵列时,我们将它减少到子阵列中的最小数字.例如,子阵列{5, 3, 5}变为{3, 3, 3}.现在,子阵列的总和被定义为所得子阵列的总和.例如,{5, 3, 5}总和是3 + 3 + 3 = 9.任务是找到可以从任何子阵列中获得的最大可能总和.对于上面的数组,最大的和是12,由子阵列给出{5, 3, 5, 4}.

是否有可能比O(n 2)更好地及时解决这个问题?

arrays algorithm sub-array

12
推荐指数
2
解决办法
1300
查看次数

两个排序数组的中位数

我的问题是参考链接的方法2 .这里给出了两个相等长度的排序数组,我们必须找到合并的两个数组的中位数.

Algorithm:

1) Calculate the medians m1 and m2 of the input arrays ar1[] 
   and ar2[] respectively.
2) If m1 and m2 both are equal then we are done.
     return m1 (or m2)
3) If m1 is greater than m2, then median is present in one 
   of the below two subarrays.
    a)  From first element of ar1 to m1 (ar1[0...|_n/2_|])
    b)  From m2 to last element of ar2  (ar2[|_n/2_|...n-1])
4) If m2 is greater than m1, then …
Run Code Online (Sandbox Code Playgroud)

algorithm merge median

10
推荐指数
2
解决办法
8890
查看次数

字大小和数据总线

对字大小的定义感到困惑.我读到处理器的字大小是它的数据总线宽度.像8位处理器一样有8位宽的数据总线.我最近读到虚拟地址空间的最大大小由字大小决定,即如果字大小是n位,则最大虚拟地址空间是2 ^ n -1.但我一直认为最大虚拟地址空间由地址总线宽度决定,即n位宽的地址总线可以寻址最大2 ^ n个字节.那么,这是真的吗?

此外,这与指针有关,因为n位数据总线只能携带n位地址.因此,可以通过指针访问最多2 ^ n个字节.

computer-architecture

8
推荐指数
1
解决办法
1万
查看次数

最好的linux发行版做内核模块编程

我想做内核模块编程.但是,所有消息来源都告诉linux发行版补丁原始内核,并且模块代码可能无法运行.如果这是真的,我该怎么办.我尝试使用ubuntu制作lfs但几乎每一步都出现错误.我看到某个地方,在安装过程中没有选择任何软件包的arch,gentoo,Ubuntu Server,slackware,susestudio等都是vanilla发行版.那么,我可以将它们用于模块编程吗?

请建议记住我需要在分发中使用GUI.

之后?
PS:我有一个intel核心i3处理器,将在vmware工作站上运行发行版.

linux kernel-module linux-from-scratch linux-distro

8
推荐指数
1
解决办法
5698
查看次数

集合的位向量实现

在阅读关于数据结构的书中关于集合的基本操作的章节时,我在主题的位向量实现中遇到了以下几行...

if the universal set is sufficiently small so that a bit vector fits in one computer word,
then union, intersection and difference can be performed by single logical operations in
the language of the underlying machine..  
Run Code Online (Sandbox Code Playgroud)

集合的一个位向量实现意味着一个集合由一个数组表示,其下标表示集合的元素,如果它是数组的成员则下标的内容为1,如果不是则为零....所以成员,插入和删除操作可以在一段时间内执行....但任何人都可以告诉我如何通过摘录中所述的单个逻辑操作来执行交集,并集和差异... plz给出一个示例(或代码) )对于三个操作中的任何一个....

algorithm set data-structures

7
推荐指数
1
解决办法
4530
查看次数

Azure 中的平均内存工作集和内存工作集

我在 Azure 中有一个应用程序服务。它显示了两个称为Average Memory Working Set和 的指标Memory Working Set。现在,Memory Working Set被定义为进程中的线程最近接触的内存页的集合。门户中显示的这两个图表如下:

在此输入图像描述 在此输入图像描述

现在,我有三个问题:

  1. 如何查明我的服务拥有的专用最大内存是多少?一旦达到限制会发生什么?
  2. 内存工作集是进程中线程最近访问的内存页数。我认为这意味着内存工作集只会在我的代码存在内存泄漏、导致其他页面加载到内存中等情况下才会增加。我的问题是任何外部因素(例如请求数量)是否会对内存工作集产生任何影响内存工作集即如果请求从 200 增加到 500,内存工作集会增加吗?如果是,为什么?

  3. 平均内存工作集是如何计算的?是按时间计算的吗?查看图表,我发现平均内存工作集和内存工作集具有几乎相似的值。

memory azure azure-web-app-service

7
推荐指数
1
解决办法
1万
查看次数

流输出和隐式void*转换操作符函数调用

像这样的代码

cin>> grade;
Run Code Online (Sandbox Code Playgroud)

grade是标准数据类型返回对cin(istream对象)的引用,它启用了级联输入....
但我读到了

cin >>grade;
Run Code Online (Sandbox Code Playgroud)

在while语句中用作条件...流的void*cast运算符函数被隐式调用...并且它将对istream对象的引用转换为非null或空指针,具体取决于上一次输入操作的成功或失败...并将空指针转换为false,将非null转换为true ...我的问题是:

  1. 什么是void*cast操作符函数以及它在这里是如何工作的
  2. 如何将非空指针转换为true并将null转换为false

c++

6
推荐指数
1
解决办法
1393
查看次数

从头开始构建linux时出现glibc错误

当我为LFS 7.1"制作"glibc-2.14.1时出现以下错误.我使用ubuntu作为主机操作系统.

gcc ../sysdeps/unix/sysv/linux/syslog.c -c -std=gnu99 -fgnu89-inline -O2 -Wall -Winline 
-Wwrite-strings -fmerge-all-constants -g -Wstrict-prototypes -mpreferred-stack-
boundary=2  -Wa,-mtune=i686 -fexceptions   -I../include -I/mnt/lfs/sources/glibc-
build/misc -I/mnt/lfs/sources/glibc-build -I../sysdeps/i386/elf -
I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386/i686 -
I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -
I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -
I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -
I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -
I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -
I../nptl/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -
I../sysdeps/i386/i686/multiarch -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -
I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -
I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -
I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -
I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl  -I.. -
I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-linux-gnu/4.6/include -isystem 
/usr/lib/gcc/i686-linux-gnu/4.6/include-fixed …
Run Code Online (Sandbox Code Playgroud)

linux makefile glibc

6
推荐指数
1
解决办法
2842
查看次数

1字节整数数据类型

我写了以下代码:

 #include <iostream>
 #include <iomanip>
 #include <stdint.h>

 using namespace std;

 int main()
 {
     uint8_t c;

     cin  >> hex >> c;
     cout << dec << c;

     return 0;
 }
Run Code Online (Sandbox Code Playgroud)

但是当我输入c-hex为12时,输出也是c.我期待着12.后来我了解到:

uint8_t通常是一个typedef unsigned char.所以它实际上读c作ASCII 0x63.

是否有一个1字节的整数,在执行I/O而不是char时表现为整数?

c++ int hex char uint8t

6
推荐指数
1
解决办法
4449
查看次数