如何使用Java计算次方(次幂)

public static void main(String args[]) {
    int num = 2;
    int pow = 5;
    System.out.print(power(num , pow));
  }
  public static int power(int a , int b) {
    int power = 1;
    for (int c = 0; c < b; c++)
      power *= a;
    return power;
  }
相关文章
相关标签/搜索