#include<stdlib.h>
int count = 0;
int find(int n)
{
if(n == 1)
{
return count;
}
if(n % 2 == 0)
{
n = n / 2;
count++;
find(n);
}
else
{
if(n > 1)
{
n = n - 1;
count++;
find(n);
}
else
{
n = n + 1;
count++;
find(n);
}
}
}
int main()
{
find(7);
printf("%d", count);
}
递归练习
最新推荐文章于 2024-07-13 21:01:13 发布