资源简介
快来下载啊,只需要1积分!!!这个是剑指offer的源码,挺全的,还有具体的测试用例~

代码片段和文件信息
// NumberOf1InBinary.cpp : Defines the entry point for the console application.
//
// 《剑指Offer——名企面试官精讲典型编程题》代码
// 著作权所有者:何海涛
#include “stdafx.h“
int NumberOf1_Solution1(int n)
{
int count = 0;
unsigned int flag = 1;
while(flag)
{
if(n & flag)
count ++;
flag = flag << 1;
}
return count;
}
int NumberOf1_Solution2(int n)
{
int count = 0;
while (n)
{
++ count;
n = (n - 1) & n;
}
return count;
}
void Test(int number unsigned int expected)
{
int actual = NumberOf1_Solution1(number);
if(actual == expected)
printf(“Solution1: Test for %p passed.\n“ number);
else
printf(“Solution1: Test for %p failed.\n“ number);
actual = NumberOf1_Solution2(number);
if(actual == expected)
printf(“Solution2: Test for %p passed.\n“ number);
else
printf(“Solution2: Test for %p failed.\n“ number);
printf(“\n“);
}
int _tmain(int argc _TCHAR* argv[])
{
// 输入0,期待的输出是0
Test(0 0);
// 输入1,期待的输出是1
Test(1 1);
// 输入10,期待的输出是2
Test(10 2);
// 输入0x7FFFFFFF,期待的输出是31
Test(0x7FFFFFFF 31);
// 输入0xFFFFFFFF(负数),期待的输出是32
Test(0xFFFFFFFF 32);
// 输入0x80000000(负数),期待的输出是1
Test(0x80000000 1);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1470 2011-09-30 15:25 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\NumberOf1InBinary.cpp
文件 4549 2011-06-20 17:29 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\NumberOf1InBinary.vcproj
文件 1417 2011-10-24 11:50 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\NumberOf1InBinary.vcproj.HAIHE-WIN7.Harry He.user
文件 1427 2015-09-08 18:48 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\NumberOf1InBinary.vcproj.USER-20150421XR.Administrator.user
文件 1362 2011-02-05 08:23 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\ReadMe.txt
文件 304 2011-02-05 08:23 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\stdafx.cpp
文件 320 2011-02-05 08:23 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\stdafx.h
文件 765 2011-02-05 08:23 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\10NumberOf1InBinary\targetver.h
文件 2553 2011-10-24 11:48 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\Power.cpp
文件 4513 2011-06-08 17:26 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\Power.vcproj
文件 1417 2011-10-24 11:50 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\Power.vcproj.HAIHE-WIN7.Harry He.user
文件 1427 2015-09-08 18:48 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\Power.vcproj.USER-20150421XR.Administrator.user
文件 1290 2011-03-16 09:58 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\ReadMe.txt
文件 292 2011-03-16 09:58 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\stdafx.cpp
文件 320 2011-03-16 09:58 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\stdafx.h
文件 765 2011-03-16 09:58 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\11Power\targetver.h
文件 2968 2011-09-30 15:25 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\Print1ToMaxOfNDigits.cpp
文件 4558 2011-06-08 17:26 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\Print1ToMaxOfNDigits.vcproj
文件 1417 2011-10-24 11:50 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\Print1ToMaxOfNDigits.vcproj.HAIHE-WIN7.Harry He.user
文件 1427 2015-09-08 18:48 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\Print1ToMaxOfNDigits.vcproj.USER-20150421XR.Administrator.user
文件 1380 2011-03-19 22:42 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\ReadMe.txt
文件 307 2011-03-19 22:42 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\stdafx.cpp
文件 320 2011-03-19 22:42 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\stdafx.h
文件 765 2011-03-19 22:42 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\12Print1ToMaxOfNDigits\targetver.h
文件 3277 2011-09-30 15:25 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\13DeleteNodeInList\DeleteNodeInList.cpp
文件 4546 2011-06-20 17:29 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\13DeleteNodeInList\DeleteNodeInList.vcproj
文件 1417 2011-10-24 11:50 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\13DeleteNodeInList\DeleteNodeInList.vcproj.HAIHE-WIN7.Harry He.user
文件 1427 2015-09-08 18:48 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\13DeleteNodeInList\DeleteNodeInList.vcproj.USER-20150421XR.Administrator.user
文件 1356 2011-03-27 23:09 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\13DeleteNodeInList\ReadMe.txt
文件 303 2011-03-27 23:09 剑指offer源码及测试用例\剑指offer源码及测试用例\InterviewQuestions\13DeleteNodeInList\stdafx.cpp
............此处省略518个文件信息
- 上一篇:配电系统可靠性实用基础(陈文高)
- 下一篇:数独问题的0-1整数规划模型
相关资源
- Scratch源码
- E4A无障碍跨程序操作类库(带源码、
- 设备管理系统源码
- 安卓wifi直连app源码
- 我的世界源码(易语言版)
- labview编程软件滤波器以及编写程序设
- 我的界面(visual foxpro)源码
- 易语言:一键cf基址源码
- The Secret Path 3D 3D魔方迷宫[源码][scra
- scratch垃圾分类源码(最终版本).sb
- VisualStudioUninstaller vs卸载工具
- 安卓QQ6.71协议源码易语言,qq协议源码
- 编译原理实验工具及参考源码(lex&
- E盾偷后台工具源码
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- UNIX/LINUX编程实践教程的源码
- 使用选择性重传协议实现UDP可靠通信
- 十以内加减法练习 powerbuilder源码
- 农场开发项目
- VC 获得文件属性 获取文件的创建时
- OCR源码
- PLC上位机编程软件
- 用foobar2000听google音乐[更新一下]
- 学生信息管理系统源码
- 读者写者问题(读者优先,写者优先
- 用VC 编写的仿QQ聊天室程序源代码
- 毕业论文之温度传感器DS18B20(源码
- 可自定义导航网站源码
- 栅栏填充算法源码(VC)
评论
共有 条评论