problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::number_of_steps_to_reduce_a_number_to_zero::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int numberOfSteps (int num)
 

详细描述

在文件 leetcode.h848 行定义.

成员函数说明

◆ numberOfSteps()

int leetcode::number_of_steps_to_reduce_a_number_to_zero::Solution::numberOfSteps ( int  num)
static

在文件 leetcode.cpp2082 行定义.

2082 {
2083 if(num == 0) {
2084 return 0;
2085 }
2086 int count = 0;
2087 while(num != 0) {
2088 if((num & 1) == 0) {
2089 count += 1;
2090 } else {
2091 count += 2;
2092 }
2093 num >>= 1;
2094 }
2095 return count - 1;
2096 }

被这些函数引用 leetcode::number_of_steps_to_reduce_a_number_to_zero::TEST().


该类的文档由以下文件生成: