2013年2月16日

数组指针:a pointer to an array,即指向数组的指针

摘要: #include <iostream>#include <stdio.h>using namespace std;int main(){ int test[2][3]={{1,2,3},{4,5,6}}; int (*A)[3]; A = &test[0];// A = test cout<<(*A)[0]<<endl; cout<<(*A)[4]<<endl; cout<<**A<<endl; cout<<**(A+1)<<endl; // cout<< 阅读全文

posted @ 2013-02-16 00:52 mymemory 阅读(267) 评论(0) 推荐(0)

2013年2月15日

GetMemory

摘要: #include <iostream>#include <stdio.h>#include <stdlib.h>#include <cstring>using namespace std; void GetMemory(char* &p, int num) { p = (char *)malloc(sizeof(char)*num); } void GetMemory1(char** p, int num) { *p=(char*)malloc(sizeof(char)*num); } char* GetMemory2(char* p, 阅读全文

posted @ 2013-02-15 18:59 mymemory 阅读(195) 评论(0) 推荐(0)

2013年2月7日

const define sizeof extern

摘要: extern:extern是全局变量声明只要声明全局变量就默认,前面加extern(程序员可以不加,但编译器默认加上)若本文件 引用别的文件中的全局变量 一定要加上extern 声明一下例如: #include "my_Fun.c" extern int b; //b是在my_Fun.c中声明了的一个全局变量 这个extern 是个声明他可以在任何地方声明 引用了一个全局变量 (可以试试 在main()函数执行完之后声明 也不会出错)这样在 工程的总头文件中就不需要考虑 先#include 哪个文件了用#include可以包含其他头文件中变量、函数的声明,为什么还要exte 阅读全文

posted @ 2013-02-07 17:49 mymemory 阅读(279) 评论(0) 推荐(0)

2013年2月5日

x&(x-1)表达式的意义

摘要: 求下面函数的返回值(微软) -- 统计1的个数-------------------------------------int func(int x){ int countx = 0; while(x) { countx++; x = x&(x-1); } return countx;}假定x = 999910011100001111答案: 8思路: 将x转化为2进制,看含有的1的个数。注: 每执行一次x = x&(x-1),会将x用二进制表示时最右边的一个1变为0,因为x-1将会将该位(x用二进制表示时最右边的一个1)变为0。 判断一... 阅读全文

posted @ 2013-02-05 15:23 mymemory 阅读(178) 评论(0) 推荐(0)

2013年1月15日

利用堆栈解决迷宫问题

摘要: View Code 1 #include <iostream> 2 3 using namespace std; 4 5 const int SIZE_X=10; 6 const int SIZE_Y=10; 7 8 //data struct 9 class mPoint 10 { 11 public: 12 mPoint(int rx=0,int ry=0,bool rcan_move_to=false) 13 { 14 x=rx; 15 y=ry; 16 can_move_to=rcan_move_... 阅读全文

posted @ 2013-01-15 16:08 mymemory 阅读(394) 评论(0) 推荐(0)

2013年1月9日

快捷键

摘要: sublimeCtrl+Enter调到下一行Ctrl+L 选择整行(按住-继续选择下行)Ctrl+KK 从光标处删除至行尾Ctrl+Shift+K 删除整行Ctrl+Shift+D 复制光标所在整行,插入在该行之前Ctrl+J 合并行(已选择需要合并的多行时)Ctrl+KU 改为大写Ctrl+KL 改为小写Ctrl+D 选词 (按住-继续选择下个相同的字符串)Ctrl+M 光标移动至括号内开始或结束的位置Ctrl+Shift+M 选择括号内的内容(按住-继续选择父括号)Ctrl+/ 注释整行(如已选择内容,同“Ctrl+Shift+/”效果)Ctrl+Shift+/ 注释已选择内容Ctrl+Z 阅读全文

posted @ 2013-01-09 15:06 mymemory 阅读(173) 评论(0) 推荐(0)

2013年1月7日

北邮人论坛python模拟登录程序

摘要: View Code 1 import urllib2,urllib 2 import sys 3 import cookielib 4 5 def login(): 6 headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1', 7 'Referer' : '******','Connection':'keep-alive'} 8 url='ht 阅读全文

posted @ 2013-01-07 20:35 mymemory 阅读(273) 评论(0) 推荐(0)

爬取人人网新鲜事python版本

摘要: View Code from sgmllib import SGMLParserimport sys,urllib2,urllib,cookielibclass spider(SGMLParser): def __init__(self,email,password): SGMLParser.__init__(self) self.h3=False self.h3_is_ready=False self.div=False self.h3_and_div=False self.a=False ... 阅读全文

posted @ 2013-01-07 15:32 mymemory 阅读(206) 评论(0) 推荐(0)

2013年1月6日

北邮校园网管登陆python脚本

摘要: View Code #!/usr/bin/env python#Author: wangkendy (wkendy@gmail.com)#2012/9/7import sysimport urllibimport getoptimport hashlibimport redef usage(): print sys.argv[0], "-a [login|logout|check] -u <username> -p <password>" sys.exit(2)def login(username, password): pid = "1& 阅读全文

posted @ 2013-01-06 04:21 mymemory 阅读(588) 评论(0) 推荐(0)

2013年1月3日

python的专用类方法

摘要: #!/usr/bin/pythonimport mathclass Vector: def __init__(self, a, b): self.a = a self.b = b def __str__(self): return 'Vector (%d, %d)' % (self.a, self.b) def __add__(self,other): return Vector(self.a + other.a, self.b + other.b) def __abs__(self): return math.... 阅读全文

posted @ 2013-01-03 11:23 mymemory 阅读(119) 评论(0) 推荐(0)

导航