PAT(B1001)

code:

	#include<stdio.h>
int main(){
	int n;
	int step=0;
	scanf("%d",&n);
	while(n!=1){
		if(n%2==0)n=n/2;
		else n=(3*n+1)/2;
		step++;
	}
	
	printf("%d",step); 
	return 0;
} 
发布了178 篇原创文章 · 获赞 64 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_42403069/article/details/102871947