给定一个字符串类型(string)表示的小数,打印出它的二进制表示。
这个题注意字符串的合法性。
不过下面的代码没有处理那种无限循环的小数,
当出现无限循环小数时,while(other>0)可能永久为true
代码:
#include
#include
std::string to_binary_string(const std::string& vNumStr)
{
std:...
分类:
其他好文 时间:
2014-09-11 01:11:31
阅读次数:
316
思路:与Binary Tree Level Order Traversal I几乎一样。只是最后将结果存放在栈里,然后在栈里再传给向量即可。再次总结思路:两个queue,先把第一个放进q1,循环q1是否为空,不为空就读取并出列,如果root有孩子就放入q2,最后清空q2。注意:for循环的时候不要使...
分类:
其他好文 时间:
2014-09-10 23:38:11
阅读次数:
274
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep...
分类:
其他好文 时间:
2014-09-10 22:23:11
阅读次数:
265
转自:http://student.zjzk.cn/course_ware/data_structure/web/chazhao/chazhao9.2.2.1.htm二分查找1、二分查找(Binary Search) 二分查找又称折半查找,它是一种效率较高的查找方法...
分类:
其他好文 时间:
2014-09-10 19:25:40
阅读次数:
305
实际中估计也没有这个需求,只是写写。
能不能直接由2进制转为16进制呢,最直接的办法是通过位移操作,也就是通常所说的 每四位二进制对应一个16进制,
假如java中有一种 二进制的基础类型 Binary bi = new Binary(11010101);这样的话 进行 bi >>> 4 位移操作 就可以很容易转换了,关于这个可以参考Integer.java中的toHexString(in...
分类:
其他好文 时间:
2014-09-10 15:54:10
阅读次数:
287
Construct Binary Tree from Preorder and Inorder Traversal
Total Accepted: 14824 Total
Submissions: 55882My Submissions
Given preorder and inorder traversal of a tree, construct the binary...
分类:
其他好文 时间:
2014-09-10 14:16:11
阅读次数:
158
??
FreeEIM Linux rpm 命令参数使用详解[介绍和应用]
RPM是RedHat Package Manager(RedHat软件包管理工具)类似Windows里面的“添加/删除程序”
rpm 执行安装包
二进制包(Binary)以及源代码包(Source)两种。二进制包可以直接安装在计算机中,而源代码包将会由RPM自动编译、安装。源代码包经常以src.r...
分类:
系统相关 时间:
2014-09-10 10:53:40
阅读次数:
370
Path Sum II
Total Accepted: 18489 Total
Submissions: 68323My Submissions
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For exampl...
分类:
其他好文 时间:
2014-09-10 01:38:49
阅读次数:
223
1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNo...
分类:
其他好文 时间:
2014-09-10 01:35:19
阅读次数:
221
http://nodejs.org/api/buffer.htmlPure JavaScript is Unicode friendly but not nice to binary data. When dealing with TCP streams or the file system, it...
分类:
Web程序 时间:
2014-09-09 23:02:59
阅读次数:
491