本人算法小菜,看见一个非常好的算法,统计一个数的二进制数的1的个数。觉得不错,与大家分享。1 int fun(int x){2 int count = 0;3 while(x){4 count++;5 x = x &(x-1)6 }7 ...
分类:
编程语言 时间:
2015-06-28 11:04:25
阅读次数:
118
C++语言的多态性 与 C++类的虚函数有关引入一个问题:定义一个基类指针,指向派生类对象,然后根据指针调用相应的方法,会有什么效果?class CBase{public: virtual void vfun() { coutvfun(); pBase->fun(); // 输出...
分类:
编程语言 时间:
2015-06-27 23:55:33
阅读次数:
161
#include
using namespace std;
int a[10]= {1,2, 3, 4, 5, 6, 7, 8, 9, 10};
int fun( int i);
int main()
{
int i ,s=0;
for( i=0; i<=10; i++)
{
try
{
s=s+fun(i);
...
分类:
其他好文 时间:
2015-06-27 16:28:28
阅读次数:
118
0x1 关于树莓派 TheRaspberry Piis a tiny and affordable computer that you can use to learn programming through fun, practical projects. 树莓派是一个小型的而且很便宜的($3.....
分类:
Web程序 时间:
2015-06-27 16:12:27
阅读次数:
256
Today,We will talk some about the argument and arguments ...#!/usr/bin/pythondef fun(*args): for value in args: print valueif __name__ == '_...
分类:
编程语言 时间:
2015-06-26 23:38:57
阅读次数:
188
#include #include #include typedef int (*PFUNC)(int,int);typedef struct{ int Position; int Length;}Fun;typedef struct{ int num; Fun *pFun;...
分类:
其他好文 时间:
2015-06-26 19:41:38
阅读次数:
115
class Base{
public:
virtual void f(){cout<<"Base::f"<<endl;}
virtual void g(){cout<<"Base::g"<<endl;}
virtual void h(){cout<<"Base::h"<<endl;}
};
typedef void (*Fun)(void);
int main(){
Base b...
分类:
编程语言 时间:
2015-06-25 23:03:04
阅读次数:
181
题目:1、一个函数fun()均匀返回0和1,各自的概率是50%,利用这个函数实现一个函数,使之返回 1的概率为3/4,0的概率为1/4。2、假如有一个函数rand5能等概率生成1 - 5 之间的整数,如何利用rand5来实现rand7?rand7函数的要求是能够等概率生成1 - 7之间的整数。思路:...
分类:
编程语言 时间:
2015-06-25 19:16:33
阅读次数:
107
概念:
早绑定指的是在编译阶段进行绑定
迟绑定指的是运行阶段绑定
例子:
Class Base
{
void fun(){}
}
Class Bind :Class Base
{
Void fun(){}
}
main()
{
Base base;
base->fun();
Bind *tmp;
tmp = &base;
tmp->fun();
...
分类:
其他好文 时间:
2015-06-25 15:37:19
阅读次数:
96
js验证表单大全 1. 长度限制 2. 只能是汉字 3." 只能是英文 4. 只能是数字 5. 只能是英文字符和数字 6. 验证油箱格式 7. 屏蔽关键字(这里屏蔽***和****) 8. 两次输入密码是否相同 路政管理系统应用: //非空验证 fun...
分类:
Web程序 时间:
2015-06-25 10:09:32
阅读次数:
178