简体   繁体   English

如何在没有“*”运算符的情况下执行乘法?

[英]How can I perform multiplication without the '*' operator?

I was just going through some basic stuff as I am learning C. I came upon a question to multiply a number by 7 without using the * operator.我在学习 C 时只是在学习一些基本的东西。我遇到了一个问题,即在不使用 * 运算符的情况下将数字乘以 7。 Basically it's like this基本上是这样的

      (x << 3) - x;

Now I know about basic bit manipulation operations, but I can't get how do you multiply a number by any other odd number without using the * operator?现在我知道基本的位操作操作,但我不知道如何在不使用 * 运算符的情况下将数字乘以任何其他奇数? Is there a general algorithm for this?有没有通用的算法?

Think about how you multiply in decimal using pencil and paper:想想你如何用铅笔和纸乘以十进制:

  12
x 26
----
  72
 24
----
 312

What does multiplication look like in binary?二进制中的乘法是什么样的?

   0111
x  0101
-------
   0111
  0000
 0111
-------
 100011

Notice anything?注意到什么了吗? Unlike multiplication in decimal, where you need to memorize the "times table," when multiplying in binary, you are always multiplying one of the terms by either 0 or 1 before writing it down in the list addends.与十进制乘法不同,您需要记住“时间表”,在二进制乘法中,您总是将其中一项乘以 0 或 1,然后再将其写在列表加数中。 There's no times table needed.不需要时间表。 If the digit of the second term is 1, you add in the first term.如果第二项的数字为 1,则添加第一项。 If it's 0, you don't.如果它是 0,你就没有。 Also note how the addends are progressively shifted over to the left.还要注意加数是如何逐渐向左移动的。

If you're unsure of this, do a few binary multiplications on paper.如果您不确定这一点,请在纸上进行一些二进制乘法。 When you're done, convert the result back to decimal and see if it's correct.完成后,将结果转换回十进制,看看它是否正确。 After you've done a few, I think you'll get the idea how binary multiplication can be implemented using shifts and adds.在你做了一些之后,我想你会明白如何使用移位和加法来实现二进制乘法。

Everyone is overlooking the obvious.每个人都忽视了显而易见的事情。 No multiplication is involved:不涉及乘法:

10^(log10(A) + log10(B))

The question says:问题说:

multiply a number by 7 without using * operator不使用 * 运算符将数字乘以 7

This doesn't use * :这不使用*

 number / (1 / 7) 

Edit:编辑:
This compiles and works fine in C:这在 C 中编译并运行良好:

 int number,result;
 number = 8;
 result = number / (1. / 7);
 printf("result is %d\n",result);

An integer left shift is multiplying by 2, provided it doesn't overflow.整数左移乘以 2,前提是它不会溢出。 Just add or subtract as appropriate once you get close.一旦接近,只需适当增加或减少。

int multiply(int multiplicand, int factor)
{
    if (factor == 0) return 0;

    int product = multiplicand;
    for (int ii = 1; ii < abs(factor); ++ii) {
        product += multiplicand;
    }

    return factor >= 0 ? product : -product;
}

You wanted multiplication without * , you got it, pal!你想要没有*乘法,你明白了,伙计!

It's easy to avoid the '*' operator:很容易避免使用“*”运算符:

mov eax, 1234h
mov edx, 5678h
imul edx

No '*' in sight.看不到“*”。 Of course, if you wanted to get into the spirit of it, you could also use the trusty old shift and add algorithm:当然,如果你想深入了解它的精神,你也可以使用可靠的旧移位并添加算法:

mult proc
; Multiplies eax by ebx and places result in edx:ecx
    xor ecx, ecx
    xor edx, edx
mul1:
    test ebx, 1
    jz  mul2
    add ecx, eax
    adc edx, 0
mul2:
    shr ebx, 1
    shl eax, 1
    test ebx, ebx
    jnz  mul1
done:
    ret
mult endp

Of course, with modern processors, all (?) have multiplication instructions, but back when the PDP-11 was shiny and new, code like this saw real use.当然,对于现代处理器,所有 (?) 都有乘法指令,但是在PDP-11闪亮而新颖的时候,这样的代码才真正有用。

Mathematically speaking, multiplication distributes over addition.从数学上讲,乘法分布于加法。 Essentially, this means:本质上,这意味着:

x * (a + b + c ...) = (x * a) + (x * b) + (x * c) ... x * (a + b + c ...) = (x * a) + (x * b) + (x * c) ...

Any real number (in your case 7 ), can be presented as a series of additions (such as 8 + (-1) , since subtraction is really just addition going the wrong way).任何实数(在您的情况下7 )都可以表示为一系列加法(例如8 + (-1) ,因为减法实际上只是加法错误)。 This allows you to represent any single multiplication statement as an equivalent series of multiplication statements, which will come up with the same result:这允许您将任何单个乘法语句表示为一系列等效的乘法语句,它们将得出相同的结果:

x * 7
= x * (8 + (-1))
= (x * 8) + (x * (-1))
= (x * 8) - (x * 1)
= (x * 8) - x

The bitwise shift operator essentially just multiplies or divides a number by a power of 2. So long as your equation is only dealing with such values, bit shifting can be used to replace all occurrence of the multiplication operator.按位移位运算符本质上只是将一个数乘以或除以 2 的幂。只要您的方程只处理这些值,就可以使用移位来替换所有出现的乘法运算符。

(x * 8) - x = (x * 2 3 ) - x = (x << 3) - x (x * 8) - x = (x * 2 3 ) - x = (x << 3) - x

A similar strategy can be used on any other integer, and it makes no difference whether it's odd or even.类似的策略可以用于任何其他整数,无论​​是奇数还是偶数都没有区别。

等同于x*8-x = x*(8-1) = x*7

Any number, odd or even, can be expressed as a sum of powers of two.任何数字,奇数或偶数,都可以表示为 2 的幂之和。 For example,例如,

     1   2   4   8
------------------
 1 = 1
 2 = 0 + 2
 3 = 1 + 2
 4 = 0 + 0 + 4
 5 = 1 + 0 + 4
 6 = 0 + 2 + 4
 7 = 1 + 2 + 4
 8 = 0 + 0 + 0 + 8
11 = 1 + 2 + 0 + 8

So, you can multiply x by any number by performing the right set of shifts and adds.因此,您可以通过执行正确的一组移位和加法将 x 乘以任何数字。

 1x = x
 2x = 0 + x<<1
 3x = x + x<<1
 4x = 0 +  0   + x<<2
 5x = x +  0   + x<<2
11x = x + x<<1 +   0  + x<<3

When it comes down to it, multiplication by a positive integer can be done like this:归根结底,乘以一个正整数可以这样完成:

int multiply(int a, int b) {
  int ret = 0;
  for (int i=0; i<b; i++) {
    ret += b;
  }
  return ret;
}

Efficient?高效? Hardly.几乎没有。 But it's correct (factoring in limits on ints and so forth).但它是正确的(考虑到整数等的限制)。

So using a left-shift is just a shortcut for multiplying by 2. But once you get to the highest power-of-2 under b you just add a the necessary number of times, so:因此,使用一个左移只是一个快捷方式由2乘以但是,一旦你到了最高功率为2的下b你只需要添加a的所需次数,所以:

int multiply(int a, int b) {
  int ret = a;
  int mult = 1;
  while (mult <= b) {
    ret <<= 1;
    mult <<= 1;
  }
  while (mult < b) {
    ret += a;
  }
  return ret;
}

or something close to that.或接近的东西。

To put it another way, to multiply by 7.换句话说,乘以 7。

  • Left shift by 2 (times 4).左移 2(乘以 4)。 Left shift 3 is 8 which is >7;左移 3 为 8,即 >7;
  • Add b 3 times.b 3 次。

One evening, I found that I was extremely bored, and cooked this up:一天晚上,我发现自己很无聊,就做了这个:

#include <iostream>

typedef unsigned int uint32;

uint32 add(uint32 a, uint32 b) {
    do {
        uint32 s = a ^ b;
        uint32 c = a & b;
        a = s;
        b = c << 1;
    } while (a & b)
    return (a | b)
}

uint32 mul(uint32 a, uint32 b) {
    uint32 total = 0;
    do {
        uint32 s1 = a & (-(b & 1))
        b >>= 1; a <<= 1;
        total = add(s1, total)
    } while (b)
    return total;
}

int main(void) {
    using namespace std;
    uint32 a, b;

    cout << "Enter two numbers to be multiplied: ";
    cin >> a >> b;

    cout << "Total: " << mul(a,b) << endl;
    return 0;
}

The code above should be quite self-explanatory, as I tried to keep it as simple as possible.上面的代码应该是不言自明的,因为我试图让它尽可能简单。 It should work, more or less, the way a CPU might perform these operations.它应该或多或少地以 CPU 执行这些操作的方式工作。 The only bug I'm aware of is that a is not permitted to be greater than 32,767 and b is not permitted to be large enough to overflow a (that is, multiply overflow is not handled, so 64-bit results are not possible).我知道的唯一错误是a不允许大于 32,767 并且b不允许大到足以溢出a (即不处理乘法溢出,因此 64 位结果是不可能的) . It should even work with negative numbers, provided the inputs are appropriately reinterpret_cast<> .它甚至应该使用负数,只要输入适当地reinterpret_cast<>

O(log(b)) method O(log(b)) 方法

public int multiply_optimal(int a, int b) {

    if (a == 0 || b == 0)
        return 0;
    if (b == 1)
        return a;
    if ((b & 1) == 0)
        return multiply_optimal(a + a, b >> 1);
    else
        return a + multiply_optimal(a + a, b >> 1);

}

The resursive code works as follows:递归代码的工作原理如下:
Base case:基本情况:
if either of the number is 0 ,product is 0.如果其中一个数字为 0,则乘积为 0。
if b=1, product =a.如果 b=1,则乘积 =a。

If b is even:如果 b 是偶数:
ab can be written as 2a(b/2) ab 可以写成 2a(b/2)
2a(b/2)=(a+a) (b/2)=(a+a) (b>>1) where'>>' arithematic right shift operator in java. 2a(b/2)=(a+a) (b/2)=(a+a) (b>>1) where'>>' java中的算术右移运算符。

If b is odd:如果 b 是奇数:
ab can be written as a+a(b-1) ab 可以写成 a+a(b-1)
a+a(b-1)=a+2a(b-1)/2=a+(a+a)(b-1)/2=a+(a+a)((b-1)>>1) a+a(b-1)=a+2a(b-1)/2=a+(a+a)(b-1)/2=a+(a+a)((b-1)>>1)
Since b is odd (b-1)/2=b/2=b>>1由于 b 是奇数 (b-1)/2=b/2=b>>1
So ab=a+(2a*(b>>1))所以 ab=a+(2a*(b>>1))
NOTE:each recursive call b is halved => O(log(b))注意:每个递归调用 b 减半 => O(log(b))

unsigned int Multiply(unsigned int m1, unsigned int m2)
{
    unsigned int numBits = sizeof(unsigned int) * 8; // Not part of the core algorithm
    unsigned int product = 0;
    unsigned int mask = 1;
    for(int i =0; i < numBits; ++i, mask = mask << 1)
    {
        if(m1 & mask)
        {
            product += (m2 << i);
        }
    }
    return product;
}

@Wang, that's a good generalization. @Wang,这是一个很好的概括。 But here is a slightly faster version.但这里有一个稍微快一点的版本。 But it assumes no overflow and a is non-negative.但它假设没有溢出并且 a 是非负的。

int mult(int a, int b){
    int p=1;
    int rv=0;
    for(int i=0; a >= p && i < 31; i++){
        if(a & p){
            rv += b;
        }
        p = p << 1;
        b = b << 1;
    }

    return rv;
}

It will loop at most 1+log_2(a) times.它最多循环 1+log_2(a) 次。 Could be faster if you swap a and b when a > b.如果在 a > b 时交换 a 和 b,可能会更快。

unsigned int Multiply( unsigned int a, unsigned int b )
{
    int ret = 0;
    // For each bit in b
    for (int i=0; i<32; i++) {

        // If that bit is not equal to zero
        if (( b & (1 << i)) != 0) {

            // Add it to our return value
            ret += a << i;
        }
    }
    return ret;
}

I avoided the sign bit, because it's kind of not the subject of the post.我避免了符号位,因为它不是帖子的主题。 This is an implementation of what Wayne Conrad said basically.这是韦恩康拉德所说的基本实现。Here is another problem is you want to try more low level math operations.这是另一个问题,您想尝试更多的低级数学运算。 Project Euler is cool!欧拉计划很酷!

Shift and add doesn't work (even with sign extension) when the multiplicand is negative.当被乘数为负时,Shift 和 add 不起作用(即使有符号扩展)。 Signed multiplication has to be done using Booth encoding :必须使用Booth 编码来完成有符号乘法:

Starting from the LSB , a change from 0 to 1 is -1;LSB开始,从 0 到 1 的变化是 -1; a change from 1 to 0 is 1, otherwise 0. There is also an implicit extra bit 0 below the LSB.从 1 到 0 的变化为 1,否则为 0。在 LSB 下面还有一个隐含的额外位 0。

For example, the number 5 (0101) will be encoded as: (1)(-1)(1)(-1).例如,数字 5 (0101) 将被编码为:(1)(-1)(1)(-1)。 You can verify this is correct:您可以验证这是正确的:

5 = 2^3 - 2^2 + 2 -1 5 = 2^3 - 2^2 + 2 -1

This algorithm also works with negative numbers in 2's complement form:该算法也适用于 2 的补码形式的负数:

-1 in 4-bit 2's complement is 1111. Using the Booth algorithm: (1)(0)(0)(0)(-1), where there is no space for the leftmost bit 1 so we get: (0)(0)(0)(-1) which is -1. -1 在 4 位 2 的补码中是 1111。 使用 Booth 算法: (1)(0)(0)(0)(-1),其中最左边的位 1 没有空间,所以我们得到: (0) (0)(0)(-1) 即 -1。

/* Multiply two signed integers using the Booth algorithm */
int booth(int x, int y)
{
    int prev_bit = 0;
    int result = 0;

    while (x != 0) {
        int current_bit = x & 0x1;
        if (prev_bit & ~current_bit) {
            result += y;
        } else if (~prev_bit & current_bit) {
            result -= y;
        }

        prev_bit = current_bit;

        x = static_cast<unsigned>(x) >> 1;
        y <<= 1;
    }

    if (prev_bit)
        result += y;

    return result;
}

The above code does not check for overflow.上面的代码不检查溢出。 Below is a slightly modified version that multiplies two 16 bit numbers and returns a 32 bit number so it never overflows:下面是一个稍微修改的版本,它将两个 16 位数字相乘并返回一个 32 位数字,因此它永远不会溢出:

/* Multiply two 16-bit signed integers using the Booth algorithm */
/* Returns a 32-bit signed integer */
int32_t booth(int16_t x, int16_t y)
{
    int16_t prev_bit = 0;
    int16_t sign_bit = (x >> 16) & 0x1;
    int32_t result = 0;
    int32_t y1 = static_cast<int32_t>(y);

    while (x != 0) {
        int16_t current_bit = x & 0x1;
        if (prev_bit & ~current_bit) {
            result += y1;
        } else if (~prev_bit & current_bit) {
            result -= y1;
        }

        prev_bit = current_bit;

        x = static_cast<uint16_t>(x) >> 1;
        y1 <<= 1;
    }

    if (prev_bit & ~sign_bit)
        result += y1;

    return result;
}
import java.math.BigInteger;

public class MultiplyTest {
    public static void main(String[] args) {
        BigInteger bigInt1 = new BigInteger("5");
        BigInteger bigInt2 = new BigInteger("8");
        System.out.println(bigInt1.multiply(bigInt2));
    }
}

In C#:在 C# 中:

private static string Multi(int a, int b)
{
    if (a == 0 || b == 0)
        return "0";

    bool isnegative = false;

    if (a < 0 || b < 0)
    {
        isnegative = true;

        a = Math.Abs(a);

        b = Math.Abs(b);
    }

    int sum = 0;

    if (a > b)
    {
        for (int i = 1; i <= b; i++)
        {
            sum += a;
        }
    }
    else
    {
        for (int i = 1; i <= a; i++)
        {
            sum += b;
        }
    }

    if (isnegative == true)
        return "-" + sum.ToString();
    else
        return sum.ToString();
}

JAVA:爪哇:
Considering the fact, that every number can be splitted into powers of two:考虑到这样一个事实,每个数字都可以分成 2 的幂:

1 = 2 ^ 0
2 = 2 ^ 1
3 = 2 ^ 1 + 2 ^ 0
...

We want to get x where:我们想要得到 x 在哪里:
x = n * m

So we can achieve that by doing following steps:因此,我们可以通过执行以下步骤来实现:

1.   while m is greater or equal to 2^pow:
     1.1  get the biggest number pow, such as 2^pow is lower or equal to m
     1.2  multiply n*2^pow and decrease m to m-2^pow
2.   sum the results

Sample implementation using recursion:使用递归的示例实现:

long multiply(int n, int m) {
    int pow = 0;
    while (m >= (1 << ++pow)) ;
    pow--;
    if (m == 1 << pow) return (n << pow);
    return (n << pow) + multiply(n, m - (1 << pow));
}

I got this question in last job interview and this answer was accepted.我在上次工作面试中遇到了这个问题,这个答案被接受了。

EDIT: solution for positive numbers编辑:正数的解决方案

这是最简单的正数 C99/C11 解决方案:

unsigned multiply(unsigned x, unsigned y) { return sizeof(char[x][y]); }

If you can use the log function:如果可以使用日志功能:

public static final long multiplyUsingShift(int a, int b) {
    int absA = Math.abs(a);
    int absB = Math.abs(b);

    //Find the 2^b which is larger than "a" which turns out to be the 
    //ceiling of (Log base 2 of b) == numbers of digits to shift
    double logBase2 = Math.log(absB) / Math.log(2);
    long bits = (long)Math.ceil(logBase2);

    //Get the value of 2^bits
    long biggerInteger = (int)Math.pow(2, bits);

    //Find the difference of the bigger integer and "b"
    long difference = biggerInteger - absB;

    //Shift "bits" places to the left
    long result = absA<<bits;

    //Subtract the "difference" "a" times
    int diffLoop = Math.abs(a);
    while (diffLoop>0) {
        result -= difference;
        diffLoop--;
    }

    return (a>0&&b>0 || a<0&&b<0)?result:-result;
}

If you cannot use the log function:如果无法使用日志功能:

public static final long multiplyUsingShift(int a, int b) {
    int absA = Math.abs(a);
    int absB = Math.abs(b);

    //Get the number of bits for a 2^(b+1) larger number
    int bits = 0;
    int bitInteger = absB;
    while (bitInteger>0) {
        bitInteger /= 2;
        bits++;
    }

    //Get the value of 2^bit
    long biggerInteger = (int)Math.pow(2, bits);

    //Find the difference of the bigger integer and "b"
    long difference = biggerInteger - absB;

    //Shift "bits" places to the left
    long result = absA<<bits;

    //Subtract the "difference" "a" times
    int diffLoop = absA;
    while (diffLoop>0) {
        result -= difference;
        diffLoop--;
    }

    return (a>0&&b>0 || a<0&&b<0)?result:-result;
}

I found this to be more efficient:我发现这更有效:

public static final long multiplyUsingShift(int a, int b) {
    int absA = Math.abs(a);
    int absB = Math.abs(b);

    long result = 0L;
    while (absA>0) {
        if ((absA&1)>0) result += absB; //Is odd
        absA >>= 1;
        absB <<= 1;
    }

    return (a>0&&b>0 || a<0&&b<0)?result:-result;
}

and yet another way.还有另一种方式。

public static final long multiplyUsingLogs(int a, int b) {
    int absA = Math.abs(a);
    int absB = Math.abs(b);
    long result = Math.round(Math.pow(10, (Math.log10(absA)+Math.log10(absB))));
    return (a>0&&b>0 || a<0&&b<0)?result:-result;
}
package com.amit.string;

// Here I am passing two values, 7 and 3 and method getResult() will
// return 21 without use of any operator except the increment operator, ++.
//
public class MultiplyTwoNumber {

    public static void main(String[] args) {
        int a = 7;
        int b = 3;
        System.out.println(new MultiplyTwoNumber().getResult(a, b));
    }

    public int getResult(int i, int j) {
        int result = 0;

        // Check for loop logic it is key thing it will go 21 times
        for (int k = 0; k < i; k++) {
            for (int p = 0; p < j; p++) {
                result++;
            }
        }
        return result;
    }
}
public static int multiply(int a, int b) 
{
    int temp = 0;
    if (b == 0) return 0;
    for (int ii = 0; ii < abs(b); ++ii) {
        temp = temp + a;
    }

    return b >= 0 ? temp : -temp;
}

public static int abs(int val) {

    return val>=0 ? val : -val;
}

Another thinking-outside-the-box answer:另一个开箱即用的答案:

BigDecimal a = new BigDecimal(123);
BigDecimal b = new BigDecimal(2);
BigDecimal result = a.multiply(b);
System.out.println(result.intValue());

Loop it.循环它。 Run a loop seven times and iterate by the number you are multiplying with seven.运行一个循环七次并迭代你要乘以七的数字。

Pseudocode:伪代码:

total = 0
multiply = 34

loop while i < 7

    total = total + multiply

endloop
public static void main(String[] args) {
    System.out.print("Enter value of A -> ");
    Scanner s=new Scanner(System.in);
    double j=s.nextInt();
    System.out.print("Enter value of B -> ");
    Scanner p=new Scanner(System.in);
    double k=p.nextInt();
    double m=(1/k);
    double l=(j/m);
    System.out.print("Multiplication of A & B=> "+l);
}

Let N be the number that we want to multiply with 7.设 N 为我们要乘以 7 的数字。

N x 7 = N + N + N + N + N + N + N
N x 7 = N + N + N + N + N + N + N + (N - N)
N x 7 = (N + N + N + N + N + N + N + N) - N
N x 7 = 8xN - N

As we know that, left shifting any number by one bit multiply it by 2. Hence, multiplying any number with 8 is equivalent to right shifting it by 3 bits我们知道,任何数字左移一位乘以 2。因此,任何数字乘以 8 等效于将其右移 3 位

N x 7 = (N << 3) - N 

I found this description here http://www.techcrashcourse.com/2016/02/c-program-to-multiply-number-by-7-bitwise-operator.html我在这里找到了这个描述http://www.techcrashcourse.com/2016/02/c-program-to-multiply-number-by-7-bitwise-operator.html

Hope it helps.希望它有帮助。

By making use of recursion, we can multiply two integers with the given constraints.通过使用递归,我们可以将两个整数与给定的约束相乘。

To multiply x and y, recursively add xy times.要将 x 和 y 相乘,请递归地将 xy 相加。

     #include<stdio.h>
     /* function to multiply two numbers x and y*/
     int multiply(int x, int y)
     {
        /* multiplied with anything gives */
        if(y == 0)
        return 0;

        /* Add x one by one */
        if(y > 0 )
        return (x + multiply(x, y-1));

        /* the case where y is negative */
        if(y < 0 )
        return -multiply(x, -y);
     }

     int main()
     {
       printf("\n %d", multiply(5, -11));
       getchar();
       return 0;
     }

A JavaScript approach for positive numbers一种用于正数的 JavaScript 方法

function recursiveMultiply(num1, num2){
    const bigger = num1 > num2 ? num1 : num2; 
    const smaller = num1 <= num2 ? num1 : num2; 
    const indexIncrement = 1;
    const resultIncrement = bigger;

    return recursiveMultiplyHelper(bigger, smaller, 0, indexIncrement, resultIncrement)
}

function recursiveMultiplyHelper(num1, num2, index, indexIncrement, resultIncrement){
    let result = 0;
    if (index === num2){
        return result;
    } 

    if ((index+indexIncrement+indexIncrement) >= num2){
        indexIncrement = 1;
        resultIncrement = num1;
    } else{
        indexIncrement += indexIncrement;
        resultIncrement += resultIncrement;
    }

    result = recursiveMultiplyHelper(num1, num2, (index+indexIncrement), indexIncrement, resultIncrement);
    result += resultIncrement;
    console.log(num1, num2, index, result);

    return result;
}

Think about the normal multiplication method we use想想我们常用的乘法

         1101 x        =>13
         0101          =>5
---------------------
         1101
        0000
       1101
      0000
===================        
      1000001 .        => 65

Writing the same above in the code在代码中写上同样的内容

#include<stdio.h>

int multiply(int a, int b){
    int res = 0,count =0;
    while(b>0) {
        if(b & 0x1)
            res = res + (a << count);
        b = b>>1;
        count++;
    }
    return res;
}
int main() {
    printf("Sum of x+y = %d", multiply(5,10));
    return 0;
}

非常简单,朋友...每次当你离开一个数字时,这意味着你将数字乘以2,这意味着答案是(x << 3)-x。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何正确地将以下if语句重写为条件语句? 使用乘法复合赋值运算符 - How can I properly rewrite the following if statement to a conditional statement? Using a multiplication compound assignment operator 如何在不求助于 BigInteger 的情况下处理 Java 中的 128 位小端乘法 - How can I handle 128 bit little endian multiplication in Java without resorting to BigInteger 使用Java的无*运算符的十进制乘法 - Decimal multiplication without * operator using java 如何使用 BigInteger 实现矩阵乘法? - How can I implement Matrix multiplication with BigInteger? 如何对齐和改进此乘法表? - How can i align and improve this multiplication table? 我可以在没有片段的情况下执行条件导航吗? - Can I perform conditional navigation without fragments? 如何为乘法测验执行正确的循环 - How to perform correct loop for Multiplication quiz 如何在JOptionPane中使我的按钮执行某些操作而不关闭它? - How can I make my button in JOptionPane perform some action without closing it? 如何在没有分隔符的情况下拆分单词并对 Java 8 中的拆分字符串执行操作? - How I can split a word without a delimiter and perform operations over the split string in Java 8? 在java中不使用乘法,除法和mod运算符将两个整数相除 - Divide two integers without using multiplication, division and mod operator in java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM