- 博客(10)
- 资源 (14)
- 收藏
- 关注
原创 判断一个整数是不是2的整数次幂--小米某一笔试题
#includeusing namespace std;//第一种方法利用循环bool MakeDecision(const int& M,int &pow) //pow表示M是2的多少次幂{ int i=2; int s=1; pow=0; if(M if(M==0) return true; do { s*=i; pow++; }wh
2012-05-27 14:45:48 2094 4
原创 哈希查找的应用之打印c++源文件中关键字和函数名
#include#include#include#include#include#includeusing namespace std;/*unsigned int BKDRHash(const string str){ unsigned int seed=131; unsigned int hash=0; string::const_iterator
2012-05-26 21:26:12 1489 2
原创 不使用临时变量而交换两个整形数
#include #define Swap(a,b) { (a)=(a)^(b); (b)=(a)^(b); (a)=(a)^(b); } //定义交换两个整形数的宏 int main(int argc,char **argv){ inta,b; printf("a="); scanf("%d",&a);
2012-05-25 21:44:48 760
原创 回调函数应用之比较两个对象大小
#include#include#includetypedef int (*cmp)(void const* one,void const* other); //抽象函数,比较两个对象大小int cmp_int(void const *one,void const *other) //具体函数比较两个整数大小{ const int *a=(int*)one; //必须转化
2012-05-22 21:06:43 1359
原创 回调函数应用1
#include#include#includeint input(char *&s,int len){ int i; if(len s=(char*)malloc(sizeof(len)); if(!s) return 0; char *p; char c; i=0; p=s; while((c=getchar())!='\n' && i++
2012-05-22 20:36:15 723
原创 一种克服gets函数缺陷的方法
int input(char *s,int len){ int i; if(len s=(char*)malloc(sizeof(len)); if(!s) return 0; char *p; char c; i=0; p=s; while((c=getchar())!='\n' && i++ { *p++=c; } printf("%d
2012-05-22 19:03:21 885
原创 泛型编程之查找最大值
#include#include#include#include#include#includeusing namespace std;templateclass LessThan{ public: virtual bool operator()(const T& one,const T& other)=0;};templateclass
2012-05-21 21:26:08 1008
原创 随机化快速次序选择算法
#include#include#include#include#include#includeusing namespace std;templateclass CMP //抽象操作符类{ public: virtual bool operator()(const T&one,const T&other)=0; //纯虚函数,重载操作符()};
2012-05-12 16:13:51 1560
原创 基数排序
//此类排序只适合大整数数据,且位数相等,如1234,2221,3331,1000,3333等#include#include#include#include#includeusing namespace std;templateclass CMP //抽象操作符类{ public: virtual bool operator()(const T&on
2012-05-07 17:27:40 561
原创 将文件中内容进行大小写转化
#include#include#include#include#include#includeusing namespace std;class FileNotOpen //文件无法打开异常类{public: string what() { string str="文件无法打开,没有此文件或目录!"; return str; }}
2012-05-01 14:51:42 1361
多边形游戏
2012-01-22
字符串匹配程序
2012-01-21
计算机集群
2012-01-19
大规模并行处理机系统 MPP
2012-01-18
对称多处理机
2012-01-18
Interconnection Network
2012-01-18
Communication in Multiprocessor Systems
2012-01-18
高级计算机测试
2012-01-18
高级体系结构课程纲要
2012-01-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人