将十进制转换成二进制 Convert decimal to binary
2014-03-13 22:59
274 查看
void ConvertDecimal2Bin(int dec) { vector<short> bin; if(dec > 0) { int quotient = dec; short remainder = dec; while ( quotient != 0) { remainder = quotient % 2; quotient = quotient / 2; bin.push_back(remainder); } vector <short>::iterator it = bin.end(); while(it != bin.begin()) cout << *(--it) << " "; cout << endl; } }
相关文章推荐
- 十进制字符串转成二进制(decimal to binary)
- convert-sorted-list-to-binary-search-tree(转换排序列表到二进制搜索树)
- [Introduction to programming in Java 笔记] 1.3.7 Converting to binary 十进制到二进制的转换
- 十进制字符串转成二进制(decimal to binary)
- 把排序数组转换为高度最小的二叉搜索树convert-sorted-array-to-binary-search-tree-with-minimal-height
- Leetcode Convert Sorted Array to Binary Search Tree 有序数组转换成二叉搜索树BST
- [LeetCode]Convert Sorted Array to Binary Search Tree 将有序数组转换成BST
- LeetCode OJ:Convert Sorted Array to Binary Search Tree(将排序好的数组转换成二叉搜索树)
- 1.1.9 java用二进制表示十进制整数(不用Integer.toBinaryString(N)方法)
- LeetCode OJ:Convert Sorted List to Binary Search Tree(将排序好的链表转换成二叉搜索树)
- convert decimal number to binary
- lintcode convert-sorted-array-to-binary-search-tree-with-minimal-height 把排序数组转换为高度最小的二叉搜索树
- convert decimal to binary
- Convert Sorted List to Binary Search Tree——将链表转换为平衡二叉搜索树 &&convert-sorted-array-to-binary-search-tree——将数列转换为bst
- 谈谈计算机和网络常用进位制:二进制(Binary)、十进制(Decimal)和十六进制(He
- Convert Sorted Array to Binary Search Tree转换成平衡二查搜索树
- [LintCode] 将二叉查找树转换成双链表 Convert Binary Search Tree to Doubly Linked List
- Write a program to convert decimal to 32-bit unsigned binary.
- [LeetCode 109] - 将已排序链表转换为二叉搜索树 (Convert Sorted List to Binary Search Tree)
- Convert Sorted Array to Binary Search Tree 把一个有序数组转换成BST @LeetCode