1001. 害死人不偿命的(3n+1)猜想

#include <iostream>
using namespace std;
int main()
{
 int n;
 int i = 0;
 cin >> n;
 if (n == 1)
 {
  cout << "0" << endl;
  exit(0);
 }
 else
 {
  B:if (n % 2 == 0)
  {
   n = n / 2;
   i=i+1;
   goto A;
  }
    else
    {
     n = 3 * n + 1;
     n = n / 2;
     i=i+1;
     goto A;
    }
   }
A:if (n == 1)
 cout << i << endl;
  else goto B;
  return 0;
}

posted @ 2016-09-13 20:01  code666  阅读(341)  评论(0编辑  收藏  举报