Hi, I'm trying to make codeblocks have the same environment as hydro oj does. Because codeblocks seem can tolerate more fault. For example, the code shown below is converting binary to decimal. However, seems like codeblocks can initialize the variable and make the correct result.
Take input 101 for example, the output should show a random number rather than 5.
Can anyone tell me how to get rid of this kind of automatic initialization?
#include <iostream>
using namespace std;
int main() {
long long bin;
// int ans = 0;
int ans; // can work without initializing to 0
cin >> bin;
long long num = bin;
long long x = 0;
int y = 0;
int a = 0;
int b = 1;
while (num > 0) {
x = num / 10;
y = num % 10;
ans = b * y + ans;
num = x;
b = b * 2;
}
cout << ans << endl;
return 0;
}