Windows socket通信出现接收数据时出现recv返回大于0,但缓冲区为大小为0的问题 服务端在ubuntu服务器下,客户端在windows下,采用socket进行通信,在客户端接收数据时,出现了诡异的情况,recv返回值大于0,但缓冲区大小为0,代码如下:char buff[10];int res=recv(ClientSocket, buff, 10, 0);cout << res << endl;//返回8,表示有接收到数据cout << strlen(buff) << e
codeblocks配置生成动态库.so的环境 1.建立工程,选择shared library2.compiler setting->Other compiler options: -shared -fPIC3.配置运行生成动态库的程序所需要的环境, 比如opencv可参考http://blog.csdn.net/llwjason5555/article/details/78276757, caffe可参考http://blog.csdn
幸运的袋子 题目:链接:https://www.nowcoder.com/questionTerminal/a5190a7c3ec045ce9273beebdfe029ee 来源:牛客网一个袋子里面有n个球,每个球上面都有一个号码(拥有相同号码的球是无区别的)。如果一个袋子是幸运的当且仅当所有球的号码的和大于所有球的号码的积。 例如:如果袋子里面的球的号码是{1, 1, 2, 3},这个袋子就是幸运的,因为
codeblocks配置caffe环境,调用caffe模型 1.首先需要搭配好caffe的运行环境,可参考我另一篇博客:http://blog.csdn.net/llwjason5555/article/details/624240852.打开codeblocks,建立工程,右击工程,选择Build options,Linker setting左边添加opencv动态库和/caffe/build/lib/libcaffe.so,右边添加-pthread-l
codeblocks配置opencv环境 1.首先,先安装好opencv,可参考:http://blog.csdn.net/titer1/article/details/450700652.打开codeblocks,建立工程,右击工程,选择Build options,Linker setting左边填入usr/local/lib中的全部动态库(.so)的路径3.Search directories->Compiler: 添加usr/incl
codeblocks下muduo环境的配置 1.首先,先按照教程安装编译muduo库,可参考http://blog.csdn.net/liuweihui521/article/details/525563752.打开codeblocks,建立工程,根据你前面编译的方式选择debug或者release,右键点击工程,选择Build Options,Linker setting中左边填入muduo静态库(.a)的路径以及 /usr/lib/x86
分饼干 题目:易老师购买了一盒饼干,盒子中一共有k块饼干,但是数字k有些数位变得模糊了,看不清楚数字具体是多少了。易老师需要你帮忙把这k块饼干平分给n个小朋友,易老师保证这盒饼干能平分给n个小朋友。现在你需要计算出k有多少种可能的数值 输入描述:输入包括两行: 第一行为盒子上的数值k,模糊的数位用X表示,长度小于18(可能有多个模糊的数位) 第二行为小朋友的人数n输出描述:输出k可能的数值种数,
堆砖块 题目:小易有n块砖块,每一块砖块有一个高度。小易希望利用这些砖块堆砌两座相同高度的塔。为了让问题简单,砖块堆砌就是简单的高度相加,某一块砖只能使用在一座塔中一次。小易现在让能够堆砌出来的两座塔的高度尽量高,小易能否完成呢。 输入描述: 输入包括两行: 第一行为整数n(1 ≤ n ≤ 50),即一共有n块砖块 第二行为n个整数,表示每一块砖块的高度height[i] (1 ≤ height[i]
回文序列 题目:如果一个数字序列逆置之后跟原序列是一样的就称这样的数字序列为回文序列。例如: {1, 2, 1}, {15, 78, 78, 15} , {112} 是回文序列, {1, 2, 2}, {15, 78, 87, 51} ,{112, 2, 11} 不是回文序列。 现在给出一个数字序列,允许使用一种转换操作: 选择任意两个相邻的数,然后从序列移除这两个数,并用这两个数字的和插入到这两个
一致性哈希算法 tencent2012笔试题附加题 问题描述: 例如手机朋友网有n个服务器,为了方便用户的访问会在服务器上缓存数据,因此用户每次访问的时候最好能保持同一台服务器。已有的做法是根据ServerIPIndex[QQNUM%n]得到请求的服务器,这种方法很方便将用户分到不同的服务器上去。但是如果一台服务器死掉了,那么n就变为了n-1,那么ServerIPIndex[QQNUM%n]与Server
双核处理 题目:链接:https://www.nowcoder.com/questionTerminal/9ba85699e2824bc29166c92561da77fa 来源:牛客网一种双核CPU的两个核能够同时的处理任务,现在有n个已知数据量的任务需要交给CPU处理,假设已知CPU的每个核1秒可以处理1kb,每个核同时只能处理一项任务。n个任务可以按照任意顺序放入CPU进行处理,现在需要设计一个方案让C
合唱团 题目:有 n 个学生站成一排,每个学生有一个能力值,牛牛想从这 n 个学生中按照顺序选取 k 名学生,要求相邻两个学生的位置编号的差不超过 d,使得这 k 个学生的能力值的乘积最大,你能返回最大的乘积吗? 输入描述: 每个输入包含 1 个测试用例。每个测试数据的第一行包含一个整数 n (1 <= n <= 50),表示学生的个数,接下来的一行,包含 n 个整数,按顺序表示每个学生的能力值 ai(
构造回文 题目:链接:https://www.nowcoder.com/questionTerminal/28c1dc06bc9b4afd957b01acdf046e69 来源:牛客网给定一个字符串s,你可以从中删除一些字符,使得剩下的串是一个回文串。如何删除才能使得回文串最长呢? 输出需要删除的字符个数。输入描述:输入数据有多组,每组包含一个字符串s,且保证:1<=s.length<=1000.输出描述
single-number-ii 题目:Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without us
longest-consecutive-sequence 题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given[100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is[1, 2, 3,
binary-tree-maximum-path-sum 题目:Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3Return6.程序:class Solu
best-time-to-buy-and-sell-stock-iii 题目:Say you have an array for which the i th element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You may
best-time-to-buy-and-sell-stock-ii 题目:Say you have an array for which the i th element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy o
best-time-to-buy-and-sell-stock 题目:Say you have an array for which the i th element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock)
pascals-triangle-ii 题目:Given an index k, return the k th row of the Pascal’s triangle. For example, given k = 3, Return[1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space?程序:class Solution