您当前的位置: 首页 > 

两数相除(位运算)

对方正在debug 发布时间:2020-02-15 11:12:56 ,浏览量:6

题目:https://leetcode-cn.com/problems/divide-two-integers/

class Solution {
public:
    int divide(int dividend, int divisor) {
        /*
        *两数相除求商,要求不用 乘法、除法、mod
        *思路:用左移运算符逐“位”确定商
        *注意防int溢出
        */
        int flag = 1;
        //先转成long long计算
        long long y = dividend;
        long long x = divisor;
        if(x             
关注
打赏
1688896170
查看更多评论
0.2288s