上一页 1 2 3 4 5 6 7 ··· 35 下一页
摘要: 1 // 面试题16:数值的整数次方 2 // 题目:实现函数double Power(double base, int exponent),求base的exponent 3 // 次方。不得使用库函数,同时不需要考虑大数问题。 4 5 #include <iostream> 6 #include 阅读全文
posted @ 2019-02-19 20:06 Run_For_Love 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1 #include"iostream" 2 using namespace std; 3 4 int CountDifferentBit(int m,int n) 5 { 6 int cnt=0,diff=m^n; 7 while(diff) 8 { 9 cnt++; 10 diff=(diff- 阅读全文
posted @ 2019-02-19 18:46 Run_For_Love 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1 #include"iostream" 2 using namespace std; 3 4 bool IsTwoPower(int n) 5 { 6 return !((n-1)&n); 7 } 8 9 int main() 10 { 11 int n; 12 while(cin>>n) 13 阅读全文
posted @ 2019-02-19 18:41 Run_For_Love 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 1 // 面试题15:二进制中1的个数 2 // 题目:请实现一个函数,输入一个整数,输出该数二进制表示中1的个数。例如 3 // 把9表示成二进制是1001,有2位是1。因此如果输入9,该函数输出2。 4 5 #include <cstdio> 6 7 int NumberOf1_Solution 阅读全文
posted @ 2019-02-19 18:31 Run_For_Love 阅读(236) 评论(0) 推荐(0) 编辑
摘要: // 面试题14:剪绳子 // 题目:给你一根长度为n绳子,请把绳子剪成m段(m、n都是整数,n>1并且m≥1)。 // 每段的绳子的长度记为k[0]、k[1]、……、k[m]。k[0]*k[1]*…*k[m]可能的最大乘 // 积是多少?例如当绳子的长度是8时,我们把它剪成长度分别为2、3、3的三 阅读全文
posted @ 2019-02-17 20:15 Run_For_Love 阅读(562) 评论(0) 推荐(0) 编辑
摘要: 1 #include"iostream" 2 using namespace std; 3 4 int GetMinNumber(int *data,int len) 5 { 6 int left=0,right=len-1,mid; 7 8 while(left<right-1) 9 { 10 m 阅读全文
posted @ 2019-02-17 15:20 Run_For_Love 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 1 #include"iostream" 2 #include"random" 3 using namespace std; 4 5 /* 6 void Swap(int &a,int &b) 7 { 8 int tmp; 9 tmp=a; 10 a=b; 11 b=tmp; 12 } 13 */ 阅读全文
posted @ 2019-02-17 14:39 Run_For_Love 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 个人答案: 1 #include"iostream" 2 #include"stdio.h" 3 #include"string.h" 4 using namespace std; 5 typedef long long ll; 6 const int MAXN=10000; 7 8 ll fib[ 阅读全文
posted @ 2019-02-16 22:10 Run_For_Love 阅读(147) 评论(0) 推荐(0) 编辑
摘要: #include "Queue.h" // 测试代码 void Test(char actual, char expected) { if(actual == expected) printf("Test passed.\n"); else printf("Test failed.\n"); } i 阅读全文
posted @ 2019-02-16 21:27 Run_For_Love 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 1 // 面试题8:二叉树的下一个结点 2 // 题目:给定一棵二叉树和其中的一个结点,如何找出中序遍历顺序的下一个结点? 3 // 树中的结点除了有两个分别指向左右子结点的指针以外,还有一个指向父结点的指针。 4 5 #include <stdio.h> 6 7 struct BinaryTree 阅读全文
posted @ 2019-02-16 17:34 Run_For_Love 阅读(118) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 35 下一页