摘要: // 面试题66:构建乘积数组 // 题目:给定一个数组A[0, 1, …, n-1],请构建一个数组B[0, 1, …, n-1],其 // 中B中的元素B[i] =A[0]×A[1]×… ×A[i-1]×A[i+1]×…×A[n-1]。不能使用除法。 #include <cstdio> #inc 阅读全文
posted @ 2020-04-13 23:52 源周率 阅读(116) 评论(0) 推荐(0) 编辑
摘要: // 面试题65:不用加减乘除做加法 // 题目:写一个函数,求两个整数之和,要求在函数体内不得使用+、-、×、÷ // 四则运算符号。 #include <cstdio> int Add(int num1, int num2) { int sum = 0; //和 int carry = 0; / 阅读全文
posted @ 2020-04-13 22:47 源周率 阅读(119) 评论(0) 推荐(0) 编辑
摘要: // 面试题64:求1+2+…+n // 题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case // 等关键字及条件判断语句(A?B:C)。 #include <cstdio> // 方法一 // 利用构造函数求解 class Temp { publ 阅读全文
posted @ 2020-04-13 22:05 源周率 阅读(250) 评论(0) 推荐(0) 编辑