自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(52)
  • 收藏
  • 关注

原创 智力题(第一集)

问题一:对一批编号为1~100 全部开关朝上开的灯进行以下操作 凡是1 的倍数反方向拨一次开关2 的倍数反方向又拨一次开关3 的倍数反方向 又拨一次开关。。。 问最后为关熄状态的灯的编号。 答案:1 4 16 25 36 49 64 81 100 分析: 第一步:比如这是10号灯,1,2,5,10的倍数时都会朝反的方向拨一次,再拨一次就是11的倍数才会朝相反的 方向拨了,跟10没有关系,你发

2015-05-31 20:05:55 1088 1

原创 C++左旋字符串

//左旋转字符串abcdefgh->cdefghab//循环递归法#include <iostream>#include <string.h>using namespace std;void runstring(char *str,int n){ int i = 0; int j = i+n; int len = strlen(str); char *p =

2015-05-30 20:50:56 711 1

原创 C++用模板求解开方(你不得不知道的模板带给我们的运行效率)

#include <iostream>using namespace std;template<int N,int low=0,int high=N>class Sqrt{ public: enum{mid=(low+high+1)/2}; enum{result = (mid*mid>N) ? Sqrt<N,low,mid-1> :: result : Sqrt<N

2015-05-30 17:53:38 1639

原创 C++模板求n!与1+2+...n

//求n!与1+2+...n#include <iostream>using namespace std;template<int _N=0>class A{ public: //static int const result = 3*A<_N-1>::result; enum{result=_N*A<_N-1>::result};//求n! //enum{

2015-05-30 15:15:26 2173 4

原创 C++简单贪吃蛇实现

#include <iostream>#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <deque>#include <list>#define _SIZE_ 30#define _SET_ cout<<"\033[?25l\033[0m"static int flags = 0;typedef in

2015-05-28 23:04:21 1131 1

原创 让我们一起来实现一个内存管理工具第二章(类型,cookie信息,构造,数组)

#include <iostream>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <list>#include <malloc.h>using namespace std;class String{ public: String():ptr(new char[1]) {

2015-05-28 16:27:03 684

原创 让我们一起来实现一个完整的内存管理工具(线程,内存池,萃取)

//让我们开始一个完整的内存管理工具的实现吧。///准备做一个完整的内存管理工具//涉及线程,内存池,萃取,不仅仅是new跟delete的重载(或者说是函数重载),这是我的一个雏形,大家谁有什么好的指正谢谢提出。#include <iostream>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <lis

2015-05-27 17:44:53 764

原创 C++求有序数组旋转之后的最小数字

//问题是:有一万个员工在公司上班,公司为了统计上班人的年纪分布情况,//请将这一万多的人的年纪进行排序,分析一个比较好的算法.#include <iostream>#include <vector>#include <stdlib.h>#include <string.h>#include <stdio.h>#define _MAX_AGE_ 100#define _MIN_AGE_

2015-05-25 22:57:31 553 1

原创 C++根据前序和中序构造二叉树

#include <iostream>#include <string.h>using namespace std;template<typename Type>struct Node{ Type data; Node<Type> *left; Node<Type> *right; Node(Type d = Type()):data(d),left(NULL

2015-05-25 17:05:32 3135 1

原创 C++超迷你迷宫

#include <iostream>#include <stack>using namespace std;#define _SIZE_ 10typedef int Array[_SIZE_][_SIZE_];struct Pos{ int x; int y; Pos(){} Pos(int val1,int val2):x(val1),y(val2){}

2015-05-25 10:10:56 958

原创 C++线索二叉树求最矮公共父亲节点

#include <iostream>#include <stdlib.h>#include <stack>using namespace std;class Expection//一个自定义的异常类{ public: void Null_Thing()//空指针异常. { cout<<"Expection!!!,this is null"<<e

2015-05-24 22:09:03 667

原创 C++插入排序之二路插入(环与非环的比较)

#include <iostream>using namespace std;void Grial(int a[],int n){ int i,j; i=j=0; int b[n]; b[0]=a[i]; int k; for(k=1;k<n;k++) { if(b[i]<a[k]) {

2015-05-24 20:59:15 861

原创 C++链表逆序打印节点

#include <iostream>#include <stack>using namespace std;template<typename Type>struct Node{ Type data; Node *next; Node(Type d = Type()):data(d),next(NULL){}};template<typename Type>c

2015-05-24 10:43:53 979

原创 C++用%20替换字符串中的空格(O(n)的时间效率)

#include <iostream>#include <malloc.h>#include <string.h>using namespace std;//将字符串中的空格用%20替换。void Grial(char *str){ if(str==NULL)return ; char *p = str; char *q = NULL; char buf[s

2015-05-23 21:53:22 997

原创 网络学习第七章(逻辑地址)

ip逻辑地址的划分。

2015-05-23 14:34:51 760

原创 C++双向循环链表

#include <iostream>using namespace std;template<typename Type>struct Node{ Node<Type> *next; Node<Type> *prve; Type data; Node(Type d = Type()):data(d),next(NULL),prve(NULL){} };t

2015-05-23 13:17:52 803

原创 C++红黑树的完整实现

#include <iostream>using namespace std;typedef enum Color{ RED, BLACK,}Color;template<typename Type>struct RbNode{ Color color; Type data; RbNode<Type> *parent; RbNode<Type

2015-05-22 12:19:47 1276

原创 网络学习(OSI模型与Tcp/Ip模型)

数据链路层与物理层实际上做的事情是最底两层的事情, 所有一些人将数据链路层与物理层归结为一层。

2015-05-21 13:51:52 765

原创 平衡二叉树

#include <iostream>#include <stdlib.h>#include <stack>using namespace std;template<typename Type>struct VALNode{ int bf; Type data; struct VALNode *left; struct VALNode *right;

2015-05-21 13:23:01 693

原创 线索二叉树

#include <iostream>#include <string.h>using namespace std;template<typename Type>struct ThreadNode{ Type data; struct ThreadNode<Type> *left; struct ThreadNode<Type> *right; bool lta

2015-05-19 15:36:11 616

原创 C++求数组的最大递增数组

#include <iostream>//求数组最大递增数列。using namespace std;void Grial(int a[],int b[],int &n){ int m = n; int flogs[n]; int len=1; int k = 0; int save[n]; for(int i=0;i<n;i++)

2015-05-18 15:36:48 1092

原创 网络学习第五章(路由器)

路由器动态学习从一个不稳定状态到稳定状态会需要一定的时间,我们称为收敛,我不同的协议会有不同的收敛速度,协议所应对的网络规模,使用算法等等都是不一样的,所以我们可以主观的选择不同的协议来生成我们的动态路由表。

2015-05-18 12:58:54 710

原创 网络学习第四章(交换机)

交换机就是多接口的网桥,网桥就是聪明的中继器。

2015-05-17 22:03:28 893

原创 网络学习第三章(网桥)

网桥的多个接口的集合就形成了交换机,网桥就是交换机, 在交换机中的消息同样是广播的方式传送, 交换机的工作方式下一章学习。

2015-05-16 21:44:19 871

原创 怀念这一路走来。

2015.以此怀念我一路走来。 好在我的一个师兄当年也是惨痛如斯,最后去了百度,瞬间满血,再战九月份,一日不敢懈怠。

2015-05-16 11:58:29 891 1

原创 C++(12个球问题,40g质量问题,15分钟求解问题)

这里的思想就是贪心思想,怎么做让取值范围最大我们就按这个方 向取取值,最终得到结果是{1,3,9,27}. 关键是比较的时候要怎么确定特别的球是重还是轻。

2015-05-15 20:03:18 1083

原创 网络学习第二章(中继器)

网桥实际上也跟中继器一样,但是它的实现更加复杂。

2015-05-14 14:13:42 827

原创 网络学习第一章(三大网络)

A,B的网速大小: 1.双方的本身传输速率。 2.双方的设备有关,例如网卡。 3.双方传输的介质,网线的传输速率。

2015-05-14 13:18:04 811

原创 C++散列表二次探测

#include <iostream>#include <malloc.h>using namespace std;enum KindOfStatus{ Empty=0, Avtive, Deleted,};template<typename Type>class HashTable{ public: HashTable(int sz)

2015-05-14 08:15:02 1358

原创 C++PJ智能指针

#include <iostream>using namespace std;template<typename Type>class auto_ptr{ public: auto_ptr(Type *d = NULL):ptr(d),own(d!=NULL){} auto_ptr(const auto_ptr &ap) { ptr = ap.r

2015-05-13 09:20:47 1053 3

原创 C++二叉搜索树

//////二叉搜索树.#include <iostream>using namespace std;template<typename Type>class BSTNode{ public: Type data; BSTNode<Type> *left; BSTNode<Type> *right; BSTNode(Ty

2015-05-10 20:52:32 615

原创 C++所有类型变量存储位置图解

我们平常所求的变量地址这里是逻辑关系,真实的物理地址中存储关系不是这样,即使是相同的逻辑地址也有可能对应不同的物理地址。

2015-05-10 10:41:49 2146

原创 C++链表K个节点K个节点的反转((1,2,3,4),如果k是2,反转结果是(2,1,4,3))

#include <iostream>using namespace std;struct Node{ int val; struct Node *next; Node(int x = int()):val(x),next(NULL){}};struct List{ List() { head=NULL; } void

2015-05-09 12:50:28 859

原创 C++不使用+-*/做加法.

#include using namespace std;int Add(int sum1,int sum2){ if(sum2==0)return sum1; int temp = sum1^sum2;//sum1与sum2异或求求出不同的位并置一。 int save = (sum1&sum2)<<1;//sum1&sum2求出相同位,全部左移一位,因为会 //产生进位,将产生进位

2015-05-07 17:28:51 1189

原创 C++输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,

//输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,//例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 //则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10. #include using namespace std;void Grial(int (*a)[5],int n

2015-05-06 11:25:42 2750

原创 C++求两个数的最大公约数。

#include using namespace std;int Grial(int a,int b){ if(b==0)return a; Grial(b,a%b);}int main(){ cout<<Grial(4,14)<<endl; return 0;}

2015-05-05 16:15:23 1135

原创 C++从上往下打印出二叉树的每个节点,同层节点从左至右打印(牛客剑指offer)

/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { }};*/class Solution {public: vector PrintFromTopToBottom(T

2015-05-05 15:30:28 3199

原创 C++s合并两个链表(牛客剑指offer)

/////这段代码不忍直视,想不通这样在牛客剑指offer上都可以通过.。#include using namespace std;struct ListNode{ int val; struct ListNode *next; ListNode(int x):val(x),next(NULL){}};void show(ListNode *root);class So

2015-05-05 15:00:36 629

原创 C++求连续数列之和为S的数组里面所有组合(根据公式S=(x+y)*n/2优美实现)

//博主mingliang37的思想,我后来想明白了,整理了一下. #include using namespace std;//输出所有和为S的连续整正数序列.//x.......y(这是一个连续序列)//x+.....+y=S;//还记得小时候老师要我们做的一道题吗?求1+2+3+...+100=?//(1+100).100/2=5050.//所以我们假设这个连续正整数序列是从

2015-05-05 14:14:28 1655

原创 C++数组求最大值及最小值最快方法(3[n/2]的时间效率)

#include using namespace std;//最小值和最大值的求解,时间复杂度最多是3[n/2],依据算法导论第九章.void swap(int &a,int &b){ int temp = a; a = b; b = temp;}void Grial(int a[],int n){ int i = 0; if(a[i]>a[i+1]) { swap(

2015-05-04 19:56:08 6746

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除