1.如何实现交换两个数的值void swap( int *a,int *b){int tep=*a;//*a其实就是主函数a的值,a是主函数存a数值的地址。*a =*b;*b =tep;}2.如何实现二维数组函数排序void desc( int(* a) [10] ,int i){//这样子就可以再...
分类:
其他好文 时间:
2014-07-16 19:27:27
阅读次数:
166
由于朋友一公司要做企业站,于是就买了阿里云的服务器.买完进去发现iptables 和selinux默认就是关掉的,可能是因为阿里云有云盾就可以不用自带的防火墙吧,具体配置过程如下(我边配边记录的):1,生成yum 缓存:yum makecache 速度蛮不错,生成蛮快 2,安装apache,cent...
分类:
数据库 时间:
2014-07-15 08:08:42
阅读次数:
412
问题描述题目来源:Topcoder SRM 627 Div2 BubbleSortWithReversals给定待排序数组A,在最多反转K个A的不相交子数组后,对A采用冒泡排序,问最小的swap次数是多少?冒泡排序的伪代码如下:BubbleSort(A): 循环len(A) - 1次: for i ...
分类:
其他好文 时间:
2014-07-14 22:32:28
阅读次数:
576
拷贝控制示例
那么接下来尽情欣赏这个案例吧!!!
/**
* 功能:拷贝控制示例
* 时间:2014年7月14日10:57:39
* 作者:cutter_point
*/
#include
#include
#include
#include
using namespace std;
class Folder;
/**
Message类
*/
class Message
{
fr...
分类:
编程语言 时间:
2014-07-14 17:39:36
阅读次数:
293
目前我开发的一个服务器后台程序存在这么一个问题,由于我的程序要不断的收发消息,并做统计,统计用的是stl的多重map,在统计中会不断的往map里赛数据。但是每次统计后我都会调用clear()去释放内存,但是似乎并不奏效,仍然会有泄漏的现象。查资料,map的clear是将map内容清空,但是内存并不归还给系统,而是缓冲在内存池里以方便下次调用,有人提出,可以新建一个map,将两个map做swap操作...
分类:
其他好文 时间:
2014-07-14 11:15:23
阅读次数:
318
腾讯云平台选购云服务器,我选购了suse10 64bit的系统,付款后大约2分钟提示已经分配完毕,根据IP和用户名密码登陆服务器。第一步:初始用户是root,需要自己创建用户组和用户。groupadd -g 1000 zduseradd -g zd -s /bin/csh -d /home/zd ....
分类:
其他好文 时间:
2014-07-13 17:58:36
阅读次数:
238
这里记录下堆的相关操作。
op 1:
'''
@ data: the heap array
@ p : index of parent item
@ n : number of data
@@ Swap p and it's son items, make p the largest of them
'''
def swapForMaxHeap(data, n, p):
l...
分类:
其他好文 时间:
2014-07-13 17:07:15
阅读次数:
223
1 #include 2 #include 3 #include 4 using namespace std; 5 6 void swap(int *a, int *b){ 7 int tmp; 8 tmp = *a; 9 *a = *b;10 *b = tmp;...
分类:
其他好文 时间:
2014-07-13 13:11:27
阅读次数:
190
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2014-07-12 20:39:17
阅读次数:
225
经验:当std::swap对你的类型效率不高时,提供一个swap成员函数,并确定这个函数不抛出异常
示例:
stl里的swap算法
namespace std{
template
void swap(T &a, T &b){
T temp(a);
a = b;
b = temp;
}
}
//“pimpl手法”(pointer to implementation) --> 文件间的编译依存度
class WidgetImpl{
public:
//...
pr...
分类:
编程语言 时间:
2014-07-10 19:35:50
阅读次数:
240