首页 > 试题广场 >

#includeusing&nb...

[单选题]
#include<bits/stdc++.h>
using namespace std;
int solve(int x){
if(x == 0 || x == 1){
return x;
}
if(x % 2 == 0){
return 1 + solve(x / 2);
}
else{
return 1 + solve((x + 1) / 2);
}
}
int main(){
int n = 100;
int ans = solve(n);
cout<<ans<<endl;
return 0;
}
程序的输出为(      )
  • 6
  • 7
  • 8
  • 9

这道题你会答吗?花几分钟告诉大家答案吧!