The 3n + 1 problem -题解(C语言代码) 摘要:#### 1095: The 3n + 1 problem [原题连接:The 3n +1 problem](https://www.dotcpp.com/oj/problem1000.html "…… 题解列表 2019年10月16日 0 点赞 0 评论 601 浏览 评分:0.0
The 3n + 1 problem -题解(C语言代码) 我是看了评论才注意到i,j输出的问题。但是我还有一个问题,输入1和1000000就得不到答案了,还想请教各位大佬。```c#includeintfun(intm){if(m==1)return4;inta=0,b=0;while(m!=1){if(m%2==0){m=m/2;a++;}else{m=m 题解列表 2019年10月28日 0 点赞 0 评论 607 浏览 评分:0.0
The 3n + 1 problem -题解(Java代码) ```javaimportjava.util.Scanner;/***The3n+1problem*http://www.dotcpp.com/oj/problem1095.html*题目描述:*考虑下面的算法来生成一个数字序列。*以整数n开始。 题解列表 2019年11月14日 0 点赞 0 评论 937 浏览 评分:0.0
The 3n + 1 problem -题解(C语言代码) 摘要:## 常规解法,只需要将数字转为Ascii码,A的为65. ```c #include int cmp(int n){ if (n==1){ printf("A"); }else…… 题解列表 2019年12月20日 0 点赞 0 评论 903 浏览 评分:0.0
The 3n + 1 problem -题解(C语言代码) 摘要:```c #include int main() { int n,m; int a,b; while(scanf("%d%d",&n,&m)!=EOF) // 题意是输入俩个…… 题解列表 2019年12月22日 0 点赞 0 评论 829 浏览 评分:0.0
The 3n + 1 problem -题解(C语言描述||显示33%错误原因之一) ```c#include#includeintfunction(intn){intsum=1;while(n!=1){if(n%2==0)n=n/2;elsen=3*n+1;sum++;}returnsum;}intmain(){inti,j, 题解列表 2020年01月31日 0 点赞 0 评论 578 浏览 评分:0.0
The 3n + 1 problem -题解(C++代码) #思路通过输入获得n1,n2;比较n1,n2的大小;使用for循环获得两数中循环次数的最大值,并输出。再将前面的放进循环中。#心得1.可以使用cin作为while的判断条件。例如:while(cin>>n1>>n2)2.做题时要细心,注意一些细节问题, 题解列表 2020年02月02日 0 点赞 0 评论 910 浏览 评分:0.0
The 3n + 1 problem -题解(C语言代码) 摘要:#include int main() { int x,y,i,cl,tempt,maxCL;// "cl" is circle length while(scanf("…… 题解列表 2020年02月03日 0 点赞 0 评论 608 浏览 评分:0.0
The 3n + 1 problem -题解(C语言代码) ```c#include#includeintis(intn){if(n==1)return1;if(n%2)n=3*n+1;elsen=n/2;returnis(n)+1;}intmain(){inti,j;while(scanf("%d%d", 题解列表 2020年02月08日 0 点赞 0 评论 659 浏览 评分:0.0
The 3n + 1 problem -题解(Java代码) ##刚开始没注意到一个坑,所以一直提示33%不通过;`importjava.util.Scanner;publicclassMain{publicstaticintzc(intn){ints=1;while(n!=1){if(n%2==0){n/=2;s++;}else{n=n*3+1;s++;}}r 题解列表 2020年03月04日 0 点赞 0 评论 1002 浏览 评分:0.0