自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(51)
  • 资源 (2)
  • 收藏
  • 关注

原创 缓冲区溢出_调用DOS窗口

#include #include char name[] = "\x41\x41\x41\x41" //name[0]-name[3]"\x41\x41\x41\x41" //name[4]-name[7]"\x41\x41\x41\x41" "\x12\x45\xfa\x7f" "\x55\x8B\xEC\x33\xC0""\x50\x50\x5

2012-04-14 13:01:48 430

原创 素性测试

#include #include #include #include using namespace std;class judge_prime{public: int Btest(int a,int n); int MillRab(int n); int RepeatMillRab(int n,int k);};int jud

2012-03-09 19:51:02 631

转载 RC4

/*++Copyright (c) 2009-2010 Sagittarius->Chinese watermelonModule Name: rc4.hAbstract: 加密算法RC4 *RC4 functions for HTMLDOC. * * Original code by Rob Earhart * Copyrig

2012-03-06 21:34:01 1157

转载 AES加密

aes.h/*********************************************************************************************AES的C语言实现这段代码系参考>和一些密码学资料写的,算是我的一个原创作品。 此代码仅仅作为研究AES算法之用。在效率方面没有优化,但是代码的正确性可以保证。

2012-03-04 13:36:23 424

原创 AES加密中列混合的具体算法

AES明文在加密过程中涉及到字节代换、行移位、列混合、轮密钥加等过程。这里对列混合的算法做出一些浅显的解释。列混合其实就是对一个状态的每一列去乘一个矩阵,其中乘法是在有限域GF(2^8)内进行的,不可约多项式为x^8+x^4+x^2+x+1如图:先把算法代码列出来:void AES::MixColumns(unsigned char state[][4]) //列混合

2012-03-02 19:27:17 1318

转载 DES

DES的可逆性证明:记 DES第 i轮中的主要运算为,即      Fi(Li –1,Ri -1)=(Li -1⊕f(Ri -1, Ki),R i -1) 则Fi^ 2=Fi(Li -1⊕f(Ri -1, Ki),R i -1)             =(Li -1⊕f(Ri -1, Ki)⊕f(Ri -1, Ki),R i -1)             =(Li –1

2012-02-25 13:53:04 835

原创 Eratosthenes筛法求10000以内的质数

#include using namespace std;int main(){ int prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43, 47,53,59,61,67,71,73,79,83,89,97}; //100以内的质数 int seq[10000]; for(int i=0; i<10000;

2012-02-20 14:18:53 1010

转载 typedef 函数指针的用法

typedef 函数指针的用法 在网上搜索函数指针,看到一个例子。开始没看懂,想放弃,可是转念一想,这个用法迟早要弄懂的,现在多花点时间看懂它,好过以后碰到了要再花一倍时间来弄懂它。其实很多时候都是这样,如果每次到难一点的内容,总想着下次我再来解决它,那就永远也学不到东西。后面那个例子加了注释,是我对这种用法的理解,希望对新手有所帮助。进入正文: 代码简化, 促进跨平台

2012-02-15 11:49:35 163

原创 实现随机密钥加密文章的仿射密码

#include #include #include #include using namespace std;int keyA[12]={1,3,5,7,9,11,15,17,19,21,23,25}; //具有mod26乘法逆的12个元素int keyB[26];char encode(char ch, int key_a, int key_b) //加密

2012-02-12 20:36:38 378

转载 C++中的随机函数

一、random函数不是ANSI C标准,不能在gcc,vc等编译器下编译通过。 可改用C++下的rand函数来实现。     1、C++标准函数库提供一随机数生成器rand,返回0-RAND_MAX之间均匀分布的伪随机整数。 RAND_MAX必须至少为32767。rand()函数不接受参数,默认以1为种子(即起始值)。 随机数生成器总是以相同的种子开始,所以形成的伪随机数列也相同,失去了随机

2012-02-12 19:21:37 448

原创 统计文章中英文字母的频度

#include#include#include#include#include using namespace std;int main(){ mapd; ifstream ifs("d:\\data.txt"); char c; while(ifs>>c) { if(isalpha(c)) { char word=tolo

2012-02-09 19:50:43 542

原创 仿射密码的C++实现

//加密:e(x)=(ax+b)modm;//解密:d(y)=a-1(y-b)modm;#include using namespace std;int a,b,c;void encode(char* seq, char* out) //加密函数{ int temp; char res; for(int i=0; seq[i]; ++i) {

2012-02-08 20:35:05 1203

原创 4.3 numeric limits

#include #include #include using namespace std;int main(){ cout<<boolalpha; cout::max()<<endl; cout::max()<<endl; cout::max()<<endl; cout<<endl; cout::max()<<endl; cout::

2011-12-30 20:44:46 215

原创 auto_ptr

#include namespace std{ template struct auto_ptr_ref { Y* yp; auto_ptr_ref(Y* rhs): yp(rhs) {} }; template class auto_ptr { private: T* ap; public: typedef T elem

2011-12-29 20:57:46 427

转载 反转字符串

题目要求:把字符串“I   am   a   student”反转成为“student   a   am   I”,不借助任何库函数。     字符串中单词顺序反转的方法有很多种,我们可以定义一个栈结构,根据栈的特性,先进后出。我们通过依次查找空格(在实际分析单词应用中这只是最简单的情况,单词之间可能直接用标点符号区分,但是使用标点符号并不意味着就是两个单词,西方世界计数方式喜欢使用三位数

2011-12-05 20:57:38 1257

原创 作业题3.38,关于缓冲区溢出

原题为:        输入一个16进制的字符串, 使得程序输出0xdeadbeef 程序如下:/* Bomb program that is solved using a buffer overflow attack */#include #include #include /* Like gets, except that characters are ty

2011-11-09 15:38:03 602

原创 test

1、gcc -c main.c2、gcc -o prog main.o3、objdump -d prog.exe>prog_obj.s4、gdb prog5、6、

2011-11-08 21:33:00 97

原创 test

/* Bomb program that is solved using a buffer overflow attack */#include "stdio.h"#include "stdlib.h"#include "ctype.h"#include "malloc.h"/* Like gets, except that characters are typed a

2011-11-06 21:58:45 76

转载 C程序栈原理及例子浅析

首先看如下图-1演示的用c语言编写的例子程序。    ┌————————————————————┐    │ 1.   void fun()                       │    │ 2.   {                                │    │ 3.       printf(“Hello World\n”);   │    │ 4.

2011-10-30 16:46:04 1339

原创 c语言中浮点数的表示

IEEE 754标准中,浮点数的表示方法如下:V=(-1)s×M×2E其中:1、s是符号位,占1个字符。s为1表示负数,s为0表示正数;2、M是二进制小数,32位单精度float中M占23位,形式如同fn-1fn-2。。。f1f0(n=23);3、E是指数位,32位单精度float中E占8位,形式如同ek-1。。。e1e0(k=8); 总体上,浮点数编码分作三类:1

2011-10-20 17:07:57 3876

原创 19 Froyd-Warshall算法

Froyd-Warshall算法用于求解所有点对之间的最短距离,其中权值可以为负值,但是不能有负数的环。时间复杂度为O(n^3)。        该算法的思路是,        第一步:所有从 i 到 j 的最短路径为i、j之间的权值(不相连的话就设为某个MAX数值)

2011-10-19 14:43:37 409

原创 18 Bellman-Ford算法

#include using namespace std;const int maxnum = 100;const int maxint = 99999; // 边typedef struct Edge{ int u, v; // 起点,终点

2011-10-15 09:48:05 254

原创 17 单源最短路径,以及补全16讲MST的一些代码

16、17讲开始涉及到图,光是伪代码的话实现起来不是很直接,所以干脆补全一下需要用到的图的类定义及一些成员函数,限于篇幅,成员函数、最小堆、并查集等的实现没有贴出来。 graph类定义template class Graph{public: Graph

2011-10-08 17:04:08 1159

原创 Lecture 16 最小生成树 Prim算法

Prim算法例如下面的无向连通图:  #include #include #include using namespace std;struct TreeNode // 边结点定义{public: TreeNode (int

2011-10-07 11:14:36 2915

原创 15 思考题 编辑距离

/*描述:设A和B是2个字符串。要用最少的字符操作将字符串A转换为字符串B。这里所说的字符操作包括:(1)删除一个字符;(2)插入一个字符;(3)将一个字符改为另一个字符。将字符串A变换为字符串B所用的最少字符操作数称为字符串A到B的编辑距离,记为d(A,

2011-10-01 18:03:44 1341

原创 15 动态规划-装配线调度

#include using namespace std; int n; // 一个装配线上有n个装配站int e1, e2; // 进入装配线1,2需要的时间int x1, x2;

2011-09-30 21:15:34 237

原创 15 动态规划-最长上升子序列

问题描述:给出一个序列a1,a2,a3,a4,a5,a6,a7….an,求它的一个子序列(设为s1,s2,…sn),使得这个子序列满足这样的性质,s1例如有一个序列:1  7  3  5  9  4  8,它的最长上升子序列就是 1 3 4 8 长度为4 算法一(时间

2011-09-29 20:11:15 434

原创 15.4 最长公共子序列

#include using namespace std;char x[30], y[30];int c[30][30];char b[30][30];void LCS(){ int m=strlen(x+1); int n=strlen(

2011-09-29 13:18:48 350

原创 Lecture 12 跳表

#include #include #include using namespace std;const int DefaultSize=100;template struct SkipNode{ E data; SkipNode * *

2011-09-25 14:23:29 267

原创 13 红黑树

#include using namespace std;typedef enum col{RED, BLACK} col;template class RBNode{public: RBNode(T k, RBNode* l=NULL, RB

2011-09-18 13:58:27 196

原创 12 二叉查找树

#include using namespace std;typedef struct Node //树结点定义{ int key; Node *lchild, *rchild, *parent; }Node, *BSTree; Nod

2011-09-14 16:06:47 208

原创 11.4 双重散列法

#include #include #include #include #include #define slot_size 100000 //散列槽的大小#define arr_size 80000 //动态关键字集合#define min_s

2011-09-04 12:40:20 2446

原创 11.3 除法散列法

#include #include #include #include #include #define slot_size 20000 //散列槽的大小#define arr_size 100000 //动态关键字集合#define min_si

2011-09-03 10:09:11 529

原创 9.3 最坏情况下线性时间选择

#include#include#include#define MAX_VALUE 10000#define random() rand()%MAX_VALUE#define N 10000using namespace std;int a

2011-09-01 13:39:27 341

原创 9.3 最坏情况下的线性时间选择算法

#include #include #include using namespace std; void init(vector& v, int n) //初始化,产生n个随机数{ srand((unsigned)tim

2011-08-30 16:41:22 202

原创 9.2 第i个顺序统计量

运行时间为θ(n)#include #include #include #include using namespace std; void input(vector& v) {

2011-08-29 13:42:42 271

原创 8.4 桶排序

数据在(0,1)之间#include #include #include using namespace std;/*initial arr*/void InitialArr(double *arr,int n){ srand((unsign

2011-08-26 13:55:04 177

原创 8.3 基数排序

#include #include #include using namespace std; const int NUM=3; //位数void input(vector& v) {

2011-08-25 20:00:38 142

原创 8.2 计数排序

#include #include #include using namespace std; void input(vector& v) { int data; while(cin>>data)

2011-08-24 20:20:23 167

原创 7.3 快速排序的随机化版本

运行时间为nlgn #include #include #include #include using namespace std;void input_v(vector &v){ int data; while(cin>>

2011-08-23 21:14:16 229

空空如也

空空如也

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

TA关注的人

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