- 博客(12)
- 收藏
- 关注
原创 利用Python对二进制数据进行按位处理
最近在用Python做数据包解析,遇到一些要按位处理二进制数据的问题。折腾了一个早上,大概有一点思路,记下来备忘吧。我要解决的问题是判断一个字节的某几位是否为特定的值,比如判断一个字节的前四位是不是0110。首先,创建一个文档,里面随便写点东西,保存之后用可以查看二进制数据的软件打开,我用的是notepad++里的HEX-Editor插件。可以看到字符‘a’对应的二进制数据是6
2015-02-05 12:06:32
19757
原创 各类特殊数的求解代码
1、回文数bool ispal(int n){ int m = 0; int t = n; while (t) { m = m * 10 + t % 10; t /= 10; } return m == n;}2、
2014-11-10 23:58:48
475
原创 static_cast的一个用法
#include#includeusing namespace std;class Animal{private: string type;public: Animal(){ cout<<"new animal."<<endl; }};class Dog :public Animal{private: string name;public: Dog(){
2014-06-07 15:37:58
737
原创 const的用法
#includeusing namespace std;class node{public : node(){ cout<<"new node"<<endl; } int data;};int main(){ node n; node m; node* const p = &n; const node* q=&m; p=&m; //错误,p只能指向n; q-
2014-06-07 00:50:13
460
原创 生成组合数
/** * Created by Linyue on 2014/5/12. */public class combination { public void combination(int n,int r){ int[] s=new int[r]; for (int i = 0; i < r; i++) { s[i]=i;
2014-05-13 00:31:10
419
原创 表达式求值
表达式求值。代码如下:/* * Created by Linyue on 2014/4/25. */import java.util.Stack;public class main{ public static void main(String[] args) { String a="(6+5)*8"; System.out.printl
2014-04-27 11:16:35
380
原创 JAVA下的归并排序
/* * Created by Linyue on 2014/4/25. */class Sort{ public static void mergeSort(T[] a,int first,int last){ T[] temp; temp = (T[])new Comparable[a.length]; callMergeSor
2014-04-26 16:27:22
381
原创 ContentResolver.query()的用法
自学Android 看ContentResolver的时候真是云里雾里。查了下Google的API手册,如下:public final Cursor query (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)Added in API level
2014-04-20 16:54:16
2185
原创 寻找迷宫出路
题目:用一个10*10的矩阵代表迷宫,1为障碍物,0为通路,角色只能朝上下左右四个方向移动。矩阵最外围一圈为1,代表围墙。入口坐标默认为(1,1)。输入:第一行有两个数,代表出口的横坐标和纵坐标。第二行开始输入代表迷宫的矩阵。输出:如果存在离开迷宫的路径,则离开迷宫的路径,否则输出“NoPath”。
2014-04-13 18:58:44
716
原创 C++实现矩阵乘法
#includeusing namespace std;void print(int *p,int a,int b){ for(int i=0;i<a;i++){ for (int j = 0; j < b; j++) { cout<<p[i*b+j]<<"\t"; } cout<<endl; }}void mul(int *p,int *q,int a,i
2014-03-30 14:44:34
1065
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅