- 博客(50)
- 资源 (9)
- 收藏
- 关注
原创 KMP模式匹配算法
/**************************KMP算法**************************/#include /*获取T串的next数组*/void get_next(char *T,int *next){ int i=0,j=-1; next[0]=-1; while(i<strlen(T)) { if(-1==j||T[i]==
2014-04-22 12:56:11
807
原创 BM模式匹配算法
/**************************BM算法**************************/#include int Index_BM(char *S,char *T){ int i,j,k; int S_len=strlen(S),T_len=strlen(T); for(i=0;i<S_len;i++) //遍历S串 { for(
2014-04-22 12:55:22
1045
原创 中国剩余定理 Python实现
#gcd,求最大公约数函数,递归算法,有了扩展欧几里得算法之后,此函数可以不用def _g_c_d(a,b): if 0==b: return a return gcd(b,a%b)#扩展欧几里得算法,返回值列表中,x是a的逆元(mod b),q是gcd(a,b),若x是0,则表示没有逆元#y是计算过程中的迭代的参数,可以不用管#此算法实质上是广义欧几里得除法的逆运算,用
2014-03-27 18:11:26
9571
原创 杨辉三角的队列实现
#include #include //宏定义#define OK 1#define ERROR 0//类型定义typedef int QElemType;typedef int Status;//链队结点定义typedef struct QNode{ QElemType data; struct QNode *next;}QNode,*QueueNode;
2014-03-25 15:00:55
4374
原创 Vigenere密码 Python实现
#########################Vigenere密码#########################letter_list='ABCDEFGHIJKLMNOPQRSTUVWXYZ' #字母表#根据输入的key生成key列表def Get_KeyList(key): key_list=[] for ch in key: key_list.append(
2014-03-23 21:46:05
5970
1
原创 Playfair密码 Python实现
#########################Playfair密码##########################约定1:若明文字母数量为奇数,在明文末尾添加一个'Z'#约定2:'I'作为'J'来处理#字母表letter_list='ABCDEFGHJKLMNOPQRSTUVWXYZ'#密码表T_letter=['','','','','']#根据密钥建立密码表de
2014-03-23 20:50:03
8644
2
原创 括弧匹配
#include //宏定义#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0//类型定义typedef char SElemType;typedef int Status;typedef int BOOL;//栈单元结构定义typedef struct SNode{ SElemType data;
2014-03-21 13:09:18
1182
原创 Joseph Circle(约瑟夫环)
#include //宏定义#define OK 1;#define ERROR -1;//类型预定义typedef int ElemType;typedef int Status;//定义约瑟夫环的结构,实际上是一个循环链表typedef struct CLNode{ ElemType data; struct CLNode* next;}CLNode,*Joseph
2014-03-17 13:21:49
818
原创 逆置链表
/************************************************************************************/*此程序的主要功能为建表,以及逆置建立好的表/*有些链表的函数并未用到,但是在日后的实验中,可能会被用到,因为是基本操作。/*未用到的函数已全部注释。***********************************
2014-03-17 13:12:47
919
原创 仿射加密
#####################仿射加密####################letter_list="ABCDEFGHIJKLMNOPQRSTUVWXYZ" #字母表#gcd函数,求最大公约数def gcd(a,b): if(a<b): t=a a=b b=t while(0!=b): t=a a=b b=
2014-03-17 13:09:54
1095
原创 Caesar密码
letter_list="ABCDEFGHIJKLMNOPQRSTUVWXYZ" #字母表#加密函数def Encrypt(plaintext,key): ciphertext="" for ch in plaintext: #遍历明文 if ch.isalpha(): #明文是否为字母,如果是,则判断大小写,分别进行加密 if ch.isupper():
2014-03-17 13:09:01
1345
原创 StaticLinkList 静态链表
/*不得不说,静态链表的思想很巧妙啊*/#include #define LEN 1000typedef struct{ int data; int cur;}StaticLinkList;/*Initialize the static link list*/void InitList(StaticLinkList list[]){ int i; for(i=0;i<L
2013-12-31 13:34:28
986
原创 求模m的逆元
#include using namespace std;int SolveInverse(int a,int m){ for(int i=0;i<m;i++) { if(1==(a*i)%m) { return i; } } return 0;}int main(){ int a,m; cout<<"Please
2013-12-18 22:28:39
1938
原创 模重复平方计算
#include using namespace std;#define MAXLEN 1000void Dec_To_Bin(int Dec,int *Bin,int *len){ int i=0; while(Dec) { Bin[i]=Dec%2; Dec/=2; i++; } *len=i;}int ModRepeatSqua
2013-12-16 17:43:34
1710
原创 求平方剩余
#include using namespace std;int Quadratic(int prime,int *quadratic){ for(int i=1;i<prime;i++) { quadratic[i-1]=(i*i)%prime; } return 0;}int main(){ int prime=2; int p[1000];
2013-12-16 17:41:46
1767
原创 实验9 根据材料编程
assume cs:code,ds:datadata segment d0 db 'welcome to masm' ; BL R G B I R G B d1 db 00000010b,00100100b,01110001bdata endscode segmentstart: mov ax,data m
2013-12-11 01:28:40
1130
原创 Adjacency Matrix of Graph(图的邻接矩阵)
//本文件是图的邻接矩阵的头文件,使用C++模板类封装(This file is the header file of adjacency matrix of graph,and packed by C++ template class)#ifndef MGRAPH_H#define MGRAPH_H#include #include "SeqList.h"using namespace
2013-12-01 14:41:39
5153
原创 Sequential List(顺序表)
//本文件是顺序表(Sequential List)的头文件,使用C++模板类进行封装(This file is the header file of Sequential list,and packed by C++ tempalte class)#ifndef SEQLIST_H#define SEQLIST_H#include #include "Exception.h"#incl
2013-12-01 14:31:49
1212
原创 C++ 高精度运算类(BigC类)
-------------------------------------------------------------------------------------------------------------------头文件----------------------------------------------------------------------------------
2013-12-01 14:24:56
2327
原创 实验7 寻址方式在结构化数据访问中的应用
assume cs:code,ds:data,es:tabledata segment db'1975','1976','1977','1978','1979','1980','1981','1982','1983' db'1984','1985','1986','1987','1988','1989','1990','1991','1992' db'1993','1994','1995
2013-11-27 18:46:04
1689
原创 7-1-4 双基回文数
#include #include #include using namespace std;int Is_Palindrome_Num(char* num){ int len=strlen(num); for(int i=0;i<len/2;i++) { if(num[i]!=num[len-i-1]) { return 0; } } return 1;
2013-11-18 20:08:29
1010
原创 7-1-3 分数拆分
#include using namespace std;int x=0,y=1,k=0;int main(){ while(cin>>k) { cout<<k<<endl; while((y<=2*k)) { double result=((double)k*y)/(y-k); if(((int)result==result)&&result>0)
2013-11-15 12:20:49
1230
原创 7-1-2 最大乘积
#include #include using namespace std;int n,num[18];int main(){ long long mul; long long max=0; cin>>n; for(int i=0;i<n;i++) { cin>>num[i]; } if((1==n)&&(num[0]>0)) { max=num[0]; }
2013-11-14 23:42:27
984
原创 7-1-1 除法
#include using namespace std;void Div_Print(int n){ for(int i=1;i<=9999;i++) { cout<<i*n<<'/'<<i<<'='<<n<<endl; }}int main(){ int n; cin>>n; Div_Print(n); return 0;}
2013-11-14 21:37:16
825
原创 6-3-3 二叉树重建
//刘汝佳递归真的是用成神了....如果加上那个数组s,我就是始终搞不明白右子树的后序遍历的最后一个参数为什么是s+p...#include #include char pre[500],mid[500];void Build(int n,char* pre,char* mid){ if(n<=0) { return; } int Left_Len=strchr(mid,p
2013-11-11 00:22:46
782
原创 Ubuntu 如何获取root权限
使用Ubuntu的时候,有时会需要root权限,有2种方法可以获取root权限:1、sudo 要执行的命令2、输入su命令来转成root用户,但是第一次使用的时候,需要密码,但是root用户的密码不是我们安装系统时设置的密码,这个时候可以输入 sudo passwd root 命令来设置root用户的密码,设置完毕之后使用su命令就可以直接转成root用户了。另外,在l
2013-11-10 19:51:30
1441
原创 6-3-2 二叉树层次遍历(BFS)
#include #include #include #include using namespace std;#define MAXN 256char s[MAXN+10];int failed=0;int n=0,ans[MAXN];typedef struct TNode{ int Have_Value; int v; struct TNode *Left,*R
2013-11-10 02:36:53
1154
原创 6-3-1 小球下落
#include int main(){ int D,I; while(2==scanf("%d%d",&D,&I)) { int k=1; for(int i=0;i<D-1;i++) { if(I%2) { k=k*2; I=(I+1)/2; } else { k=k*2+1; I=I/2; } }
2013-11-08 23:20:20
946
原创 6-2-2 移动的小球(数组模拟链表实现)
#include #include #define MAXN 500001using namespace std;int Left[MAXN];int Right[MAXN];void link(int X,int Y);int main(){ int X,Y,n,m; char *chOP; scanf("%d %d",&n,&m); for(int i=1;i<=n
2013-11-08 18:27:55
1274
原创 6-2-1 移动小球
#include #include using namespace std;#define MAXN 500001int A[MAXN];int find(int index,int n){ for(int i=1;i { if(index==A[i]) { return i;
2013-11-06 17:52:53
1043
原创 UVA10071 重温高中物理
#include int main(){ int v,t; while(scanf("%d%d",&v,&t)!=EOF) { printf("%d\n",2*v*t); } return 0;}
2013-11-06 16:07:14
678
原创 UVA10055 勇士Hashmat
#include int main(){ unsigned long a ,b; while(scanf("%ld%ld",&a,&b)!=EOF) { printf("%ld\n",(a>b)?(a-b):(b-a)); } return 0;}
2013-11-06 16:05:32
1062
转载 【转】枚举进程:ring3->ring0
用google搜索了几天相关内容的资料,将所提到的逐一实现。哎,不禁感叹自己太菜了。居然用了几天的时间。没啥新思想、内容,只是总结,当然还有其他方法没总结到。但经常提到的ring3下的快照、psapi的EnumProcesses、暴力OpenProcess;ring0下的ZwQuerySystemInformation、activprocess链、暴力搜索内存、PspCidTable、Csrss进
2013-08-15 20:16:29
1066
原创 实验4 [bx]和loop的使用——第二小题
assume cs:codecode segment mov ax,0 mov ds,ax mov bx,0200h mov cx,0040h s: mov [bx],bx inc bx loop s mov ax,4c00h int 21hcode endsend
2013-08-14 19:44:22
1071
原创 The Problem Of Using MessageBox() Of Win32 API
When we using the API MessageBox() of win32,we found that it require 4 parameters,this is not like that in MFC can recieve 1 parameter.So,how can we use it?Here is the introduction in MSDN for C++
2013-08-05 13:09:05
878
原创 字母重排
#include #include #include using namespace std;int CmpChar(const void* _a,const void* _b){ char* a=(char*)_a; char* b=(char*)_b; return *a-*b;}int CmpString(const void* _a,const void* _b)
2013-08-01 22:27:49
726
原创 The Logical Structure of Linear List
/*****************From this day onwards,to promote my English level,I decide to wirte blog in English.********************/Linear List is a data object such as (A1,A2,...An).The basic operation of L
2013-08-01 19:11:52
619
原创 6174问题
#include using namespace std;void SelectionSort(char *str,int len);void StrReverse(char *str,int len);int GetNext(int num);int main(){ int num[20000],count=1; cin>>num[0]; cout<<num[0]; wh
2013-07-31 22:20:59
764
原创 抽象数据类型ADT
抽象数据类型(abstruct data type,ADT)ADT的本质其实就是一种对数据结构或算法的描述语言,用“自然语言+编程语言格式”的方式对需要构造的模型来进行描述,有点类似伪代码,其实也可以认为是伪代码的说~~然而它却不能够直接被编译器编译出应用程序,因为用的是机器无法识别的自然语言,因此ADT能够起到的唯一作用就是类似与草图一样的东西,当我们想要实现某个程序的算法,或是某个数据
2013-07-30 17:40:22
2107
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人