2021年3月19日星期五

My code is never executing, it just takes in the inputs but never executes, what could be the possible problems?

Question - Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.

Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.

Limak eats a lot and his weight is tripled after every year, while Bob's weight is doubled after every year.

After how many full years will Limak become strictly larger (strictly heavier) than Bob?

Input - The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob respectively.

Output - Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.

My code -

int main(){      int a,b,i=1;      cin >> a >> b;      while(a!=b){          a = a*3;          b = b*2;          i++;      }      cout << i;  }  

But this code is never executing I cannot understand why, what is wrong in this code?

https://stackoverflow.com/questions/66718394/my-code-is-never-executing-it-just-takes-in-the-inputs-but-never-executes-what March 20, 2021 at 01:00PM

没有评论:

发表评论