- 博客(21)
- 收藏
- 关注
转载 Dijkstra最短路径算法
原文地址:http://blog.chinaunix.net/uid-26548237-id-3834514.html Dijkstra(迪杰斯特拉)算法是典型的最短路径路由算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。Dijkstra算法能得出最短路径的最优解,但由于它遍历计算的节点很多,所以效率低。 Dij
2016-10-03 13:54:24
695
原创 快速排序之python实现
快速排序的基本思想:设要排序的数组是A[0]……A[N-1],首先任意选取一个数据(通常选用数组的第一个数)作为关键数据,然后将所有比它小的数都放到它前面,所有比它大的数都放到它后面,这个过程称为一趟快速排序。值得注意的是,快速排序不是一种稳定的排序算法,也就是说,多个相同的值的相对位置也许会在算法结束时产生变动。快速排序的平均时间复杂度是:O(n)=nLog(n)def quic
2016-09-16 13:46:58
525
原创 插入排序之python实现
插入排序的定义:插入排序的基本操作就是将一个数据插入到已经排好序的有序数据中,从而得到一个新的、个数加一的有序数据,算法适用于少量数据的排序,时间复杂度为O(n^2)。是稳定的排序方法。插入算法把要排序的数组分成两部分:第一部分包含了这个数组的所有元素,但将最后一个元素除外(让数组多一个空间才有插入的位置),而第二部分就只包含这一个元素(即待插入元素)。在第一部分排序完成后,再将这个最后元素插入到
2016-09-16 11:11:18
287
转载 那些C++牛人的博客
C++大牛的博客Bjarne Stroustrup的博客: Bjarne Stroustrup’s HomepageBjarne Stroustrup,不认识的可以去面壁了,没有他,就没有我们现在的饭碗。Bjarne Stroustrup是丹麦人,目前任教于TAMU。他的Homepage和他的书籍The C++ Programming Language一样,都是百科全书
2016-08-28 22:59:26
593
转载 线程安全的 C++ Singleton 实现
原文地址:http://www.cnblogs.com/liyuan989/p/4264889.html前言前段时间在网上看到了一个百度的面试题,大概意思是如何在不使用锁和C++11的情况下,用C++实现线程安全的Singleton。看到这个题目后,第一个想法就是用Scott Meyer在《Effective C++》中提到的,把non-local static
2016-02-17 20:18:42
492
2
转载 Python yield 使用浅析
原文地址:http://www.ibm.com/developerworks/cn/opensource/os-cn-python-yield/您可能听说过,带有 yield 的函数在 Python 中被称之为 generator(生成器),何谓 generator ?我们先抛开 generator,以一个常见的编程题目来展示 yield 的概念。如何生成斐波那契數列
2016-02-13 00:06:02
318
转载 边缘触发(Edge Trigger)和条件触发(Level Trigger)
概述 边缘触发 是指每当状态变化时发生一个io事件; 条件触发 是只要满足条件就发生一个io事件; 详述 int select(int n, fd_set *rd_fds, fd_set *wr_fds, fd_set *ex_fds, struct timeval *timeout);
2016-02-12 20:49:15
640
转载 C++11 转移语义 (Move Sementics) 和精确传递 (Perfect Forwarding)
原文: http://www.ibm.com/developerworks/cn/aix/library/1307_lisl_c11/新特性的目的右值引用 (Rvalue Referene) 是 C++ 新标准 (C++11, 11 代表 2011 年 ) 中引入的新特性 , 它实现了转移语义 (Move Sementics) 和精确传递 (Perfect Forward
2016-02-11 18:59:59
2276
原创 std::lower_bound()和std::upper_bound()总结
今天看到了这std::lower_bound()和std::upper_bound()这两个函数,忘了它们用法,查询了相关资料并总结一下: 1、std::lower_bound()的函数原型为 lower_bound (ForwardIterator first, ForwardIterator last,const T& val) ,它返回第一个不小于val的迭代器,而元素间比较函
2016-02-10 23:49:28
2946
原创 POJ 3273 二分法穷举
看了题目没有想法,参考了其他同学的做法后,自己写了一个DescriptionFarmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exac
2016-02-10 21:35:38
329
原创 POJ 3687 拓扑排序应用
DescriptionWindy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that:No two balls share the same label.The labeling satisfies seve
2016-02-09 23:00:03
281
原创 POJ 3069
DescriptionSaruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the
2016-02-06 20:38:57
260
原创 POJ3083 DFS&BFS
DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terro
2016-02-06 20:36:41
300
原创 POJ 3069
DescriptionSaruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the
2016-02-06 17:39:33
239
原创 POJ 3026 bfs+最小生成树的应用
DescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg
2016-02-03 09:45:05
267
原创 easyMath.py
from operator import add,subfrom random import randint,choiceops={'+':add,'-':sub}TRYTIMES=2def dopbox(): op=choice('+-') nums=[randint(1,10) for i in range(2)] nums.sort(reverse=T
2016-01-31 15:41:38
388
原创 POJ3411 DFS最小计算消费值
DescriptionA network of m roads connects N cities (numbered from 1 to N). There may be more than one road connecting one city with another. Some of the roads are paid. There are two ways to pay fo
2016-01-30 19:54:09
388
原创 最短路径问题 POJ3767
DescriptionThe country is facing a terrible civil war----cities in the country are divided into two parts supporting different leaders. As a merchant, Mr. M does not pay attention to politics but
2016-01-21 20:16:38
438
转载 两种高性能I/O设计模式(Reactor/Proactor)的比较
转载一篇总结得很好的描述Reactor/Proactor模型的文章译文: http://blog.jobbole.com/59676/原文: http://www.artima.com/articles/io_design_patterns.html
2016-01-07 21:16:12
343
原创 poj3096
好久没写了#include #include #include using namespace std;bool IsSurprisingWord(const string Str){if (Str.length()int D=Str.length()-2;int i,j;string A,B,C;set ST;for (int ic=1;ic{
2015-02-23 20:29:18
303
原创 基于TCP的服务器和客户端的简单收发Demo
///#include #include #include using namespace std;#pragma comment (lib,"WS2_32.lib")#define BUFFSIZE 512int main(){WSADATA wsd;SOCKET SServer,SClient;int returnval,ClientLe
2014-09-07 16:10:06
524
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人