紫竹


私信TA

用户名:urnachan

访问量:28832

签 名:

等  级
排  名 303
经  验 5421
参赛次数 0
文章发表 72
年  龄 0
在职情况 学生
学  校 合肥工业大学
专  业

  自我简介:

TA的其他文章

#include "stdio.h"                             //数值较大时会挂掉

#include "string.h"

#define max(a,b) a>b?a:b

int fun(int a)

{

static int count = 1;

int i;

if (a == 1)

{

i = count;

count = 1;

return i;

}

else

{

if (a % 2 == 0)

{

a /= 2;

count++;

return fun(a);

}

else

{

a = a * 3 + 1;

count++;

return fun(a);

}

}

}

int main()

{

int x[100],y[100],i=0,j,k,max=0;

while (scanf("%d %d", &x[i], &y[i]) != EOF)

{

i++;

};

j = i;

for (i = 0; i < j; i++)

{

for (k = x[i]; k <= y[i]; k++)

{

max = max(max, fun(k));

}

printf("%d %d %d\n", x[i], y[i], max);

max = 0;

}

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区