Skip to content

Instantly share code, notes, and snippets.

@frops
Created July 6, 2019 13:52
Show Gist options
  • Save frops/aedd36d88cc06410d65f0f2e6816fa38 to your computer and use it in GitHub Desktop.
Save frops/aedd36d88cc06410d65f0f2e6816fa38 to your computer and use it in GitHub Desktop.
Where is bug? What is wrong?
#include <iostream>
using namespace std;
int log(int a)
{
int cnt;
while (a > 1)
{
a /= 2;
cnt++;
}
return cnt;
}
int main()
{
int t, a;
cin >> t;
while (t-- > 0)
{
cin >> a;
cout << log(a) << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment