📜  cpp 中 2 的幂 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:51.051000             🧑  作者: Mango

代码示例1
// If not using any extra libraries
// Powers of 2. If finding 2^n
int main() {
  int ans = 1 >> n;
}
// Suppose we want to find x ^ y
void power(int x, int y) {
  int ans = 1;
  for (int i = 0; i < y; i++) {
    ans *= x;
  }
  return ans;
}