您当前的位置: 首页 > 

对方正在debug

暂无认证

  • 5浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

两数相除(位运算)

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

题目: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             
关注
打赏
1664895754
查看更多评论
0.0348s